Game Development Community

Threading with Torque Script

by Leonardo Ferrer · in Torque Game Engine · 07/13/2007 (8:23 am) · 7 replies

Is it possible to implement Multithreading with TorqueScript or it has to be implemented directly in the C++ code like in the article in the TDN?

#1
07/13/2007 (8:28 am)
This question was asked and answered already--the answer isn't going to change in a new forum :)

multi-threading is a very fundamental and very complex design/implementation technique, and TorqueScript in no way supports it.
#2
07/13/2007 (8:37 am)
Does Torque support it? I've noticed a number of Torque based games entered in the Intel contest that are entered in the "Threaded" category and have wondered whether Torque had native threading support.
#3
07/13/2007 (9:14 am)
Tim:

These games might not use Torque script, or use it partially, and most of their code might be written on C++.
#4
07/13/2007 (9:17 am)
Torque Game Engine is not itself threaded, but is thread safe at the lowest levels (ConsoleObject, SimObject, SimEvent) to allow for relatively easy communication between threads.

TGE-A has extended use of threading, specifically for Atlas2 terrains.

Neither is designed or implemented as a "highly threaded" engine (which isn't necessarily a good thing for game development--John Carmack wrote an article a couple of years ago discussing the benefits and issues of threading a game engine, and basically concluded that for the most part the benefits weren't worth the challenges and issues).
#5
07/13/2007 (9:17 am)
@ Kostya Teterin

That wasn't my question, but thanks anyway :)

@ Stephen

Thanks for answering my question!
#6
07/13/2007 (4:10 pm)
We've a threaded version of Torque running and can agree with the conclusions drawn for most parts there isn't a lot of gain, the area where we do see a big advantage is the data access (read and writes to a database) which are amongst one of the slowest things imagineable.

TGE comes with support for threads in as much as there are classes for creating threads (posix for mac, sdl for linux, can't remember what windows version uses), mutexes and semaphores - sadly there's no condition variables in stock tge (although we're thinking of adding them as it would be beneficial to us)

If I remember correctly the theora stuff is threaded in stock tge but that's it.
#7
07/14/2007 (10:43 am)
Stock Windows version uses the native Windows API.

I migrated our 1.3 codebase to link against pthreads-win32 (http://sourceware.org/pthreads-win32/), and created a single cross-platform thread API, which includes a Condition class. The API is close to the stock TGE one, but not identical.

Getting condition variables is great, and it's really nice to have the same thread semantics and POSIX conformance across platforms.