Public Member Functions |
| | ThreadGroup (int _count) |
| | ~ThreadGroup () |
| | Destroys the thread group created by createGroup().
|
| void | abort () |
| | Signals to all active threads in the group that it is time to stop.
|
| LWMTThreadID | addThread (LWMTThreadFunc func, int size, void *arg) |
| | Adds thread functions to the thread group.
|
| LWMTThreadID | addThread (Thread *func) |
| virtual bool | available () const |
| | Check if the global is available.
|
| bool | begin () |
| | Causes the threads managed by the group to leave their suspended state, and begin execution (simultaneously, non-blocking).
|
| virtual LWMTUtilFuncs * | getGlobal () |
| | Get the pointer to the global.
|
| int | getThreadCount () |
| | Returns the number of threads the specified group is managing.
|
| LWMTThreadID | getThreadID (int in_index) |
| | Given a thread index (thrdndx), this function will return that thread's identifier.
|
| bool | isAborted () |
| | This query function tests to see if the threads in the group were aborted for some reason.
|
| bool | isDone () |
| | This query function tests to see if all the threads in the group have terminated.
|
| void | kill () |
| | This function summarily terminates all active threads in the group.
|
| int | lockMutex (int mutexID) |
| | Attempts to gain a lock on the group's indicated mutex.
|
| LWMTUtilFuncs * | operator-> () |
| | Get the pointer to the global.
|
| bool | run () |
| | Causes the threads managed by the group to leave their suspended state, and begin execution (simultaneously, blocking).
|
| void | sync () |
| | Once started by groupBegin, this function will block the calling process until all active threads in the group complete.
|
| int | threadResult (int in_index) |
| | The result (i.e, the return code) of an individual thread can be queried using this function.
|
| int | unlockMutex (int mutexID) |
| | Releases a lock on a group's mutex.
|
Cross-platform threading support is provided by the functions in the following sections. Threads are powerful tools for the developer that allow simultaneous paths of execution to exist within the same application. On single-core, single-processor systems, threads typically execute synchronously. However, on multi-processor (or multi-core) systems, threads will often execute in true parallel, allowing the application to be more responsive than would be allowed by a single-path execution model.
- Note:
- These functions only provide the mechanism for multi-threading. What you do within the threads you create is entirely your concern. The responsibility lies with you, the developer, to ensure that the functions you call from within your thread that lead to paths outside your thread are safe to be called in that fashion (i.e., "thread-safe"). The practice of calling LightWaveŽ Plug-In API functions from within a thread is not officially supported. Please be aware that such a practice is undertaken by you at your own risk.
| LWMTThreadID lwpp::ThreadGroup::addThread |
( |
LWMTThreadFunc |
func, |
|
|
int |
size, |
|
|
void * |
arg |
|
) |
| |
|
inline |
Adds thread functions to the thread group.
The function to be added must match the LWMTThreadFunc signature. Each thread must accept a single void * argument, which is a pointer to the thread argument data argvalue.
This thread argument can be specified by the argvalue parameter. If argsize is greater than zero (i.e., it specifies the size of the data pointed to by argvalue), then the value pointed to by argvalue will be passed to the thread fuction by value (a copy is made). On the other hand, if argsize is zero, then argvalue will be passed to the thread function by reference (i.e., the actual pointer will be provided).
As threads are added to the group, they are maintained in a suspended state. Threads do not start until the group launches them with one of the execution functions (see below).