Public Types | |
typedef void(* | ThreadFunction) (unsigned index, unsigned nThreads, void *userData) |
Static Public Member Functions | |
static bool | spawn (ThreadFunction, unsigned nThreads, void *userData) |
static ThreadId | GetThreadId () |
static const ThreadInfo * | thisThread () |
static int | thisIndex () |
static bool | OnMainThread () |
returns true if we're on the main-thread, false otherwise | |
static void | terminate_all () |
static bool | running (void *userData) |
static void | wait (void *userData) |
static RunningThreadsInfo | getRunningThreadsInfo () |
Static Public Attributes | |
static unsigned | numCPUs |
recommended count for compute-only threads | |
static unsigned | numThreads |
recommended count for threads that will do I/O | |
static unsigned | numThreadsPerReadWriteTask |
number of threads to use when multi-threading read or write ops in NukeEngine | |
static size_t | gMinStackSize |
the minimum stack size each pthread can have | |
static const size_t | kAbsoluteMinStackSize |
absolute minimum stack size permissible | |
Namespace of functions to create and wait for parallel threads.
"Real" threads as seen by the operating system are reused. After the function passed to spawn() returns, the thread will wait until another spawn() is called and will pick up the function from that. Therefore the operating system overhead of creating and destroying threads is avoided and you can call spawn() as much as you want even with short functions.
For synchronization see the classes Lock, SignalLock, and Guard.
|
static |
Start nThreads parallel threads, all running function. The arguments to function are an index number between 0 and nThreads-1, nThreads, and the userData argument.
References gMinStackSize.
Referenced by DD::Image::ImagePlane::fillChannelThreaded(), and DD::Image::ToBuffer::to_buffer().
|
static |
Returns an OS agnostic thread ID.
Referenced by thisThread().
|
static |
Returns a pointer to a structure containing the arguments passed to the spawn() that launched this thread, and the index number passed to the function for this thread. This pointer is good until the thread function exits.
Returns null if this thread does not appear to have been launched by spawn(), this is usually because you are in the main thread.
References GetThreadId().
|
static |
Destroys all the threads. This is used on program exit to because some systems (Linux?) don't seem to get rid of parallel threads on normal exit!
|
static |
Return true if any threads launched by a call to spawn() with the given userData are still running.
|
static |
Wait until all threads launched by a call to spawn() with the given userData have exited.
Referenced by DD::Image::ImagePlane::fillChannelThreaded(), DD::Image::ToBuffer::to_buffer(), and DD::Image::Interest::~Interest().
|
static |
Get info on the running threads
©2019 The Foundry Visionmongers, Ltd. All Rights Reserved. |