Regina Calculation Engine
|
Provides very basic thread handling. More...
#include <utilities/nthread.h>
Public Member Functions | |
virtual | ~NThread () |
Destroys this thread. More... | |
bool | start (void *args=0, bool deleteAfterwards=false) |
Starts a new thread and performs run() within this new thread. More... | |
void | join () |
Waits for a previously-started thread to terminate. More... | |
virtual void * | run (void *args)=0 |
The routine to run in the new thread when start(void*, bool) is called. More... | |
Static Public Member Functions | |
static bool | start (void *(*routine)(void *), void *args, NThreadID *id) |
Starts a new thread that performs the given routine. More... | |
static void | yield () |
Causes the currently running thread to voluntarily relinquish the processor. More... | |
Provides very basic thread handling.
Throughout this documentation, "thread object" refers to an instance of an NThread subclass, and otherwise "thread" has its usual meaning as a thread executing code in the underlying operating system.
Each subclass of NThread represents a specific task that new threads can perform. Each subclass should override run() to perform its corresponding task. The user may then create a thread object and call start() upon it, which will spawn a new thread that executes run().
A thread object is called running if its corresponding thread is running. You must not call start() on a thread object that is already running. Instead, if you wish to run multiple instances of the same task in parallel, you must start these from different thread objects.
|
inlinevirtual |
Destroys this thread.
|
inline |
Waits for a previously-started thread to terminate.
Once this function returns, it is guaranteed that the thread is no longer running.
false
(the default).
|
pure virtual |
The routine to run in the new thread when start(void*, bool) is called.
args | the argument passed to start(void*, bool). |
Implemented in regina::NGenericFacetPairing< dim >, regina::NGenericFacetPairing< 2 >, and regina::NGenericFacetPairing< 3 >.
bool regina::NThread::start | ( | void * | args = 0 , |
bool | deleteAfterwards = false |
||
) |
Starts a new thread and performs run() within this new thread.
The return value of run() is ignored.
true
, you must not attempt to access this thread object again (since it could be deleted at any time). In particular, you will not be able to call join() to wait for the new thread to terminate.args | the arguments to pass to run() when it is started. |
deleteAfterwards | true if this NThread object should be deleted once run() has finished. |
true
if and only if the new thread was successfully started.
|
static |
Starts a new thread that performs the given routine.
The return value of the given routine is currently ignored.
routine | the routine to run in the new thread. |
args | the arguments to pass to routine when it is started. |
id | a location in which the ID of the new thread will be placed, or 0 if the new thread ID is not required. If non-zero, this parameter must point to an already extisting NThreadID that may contain any value. |
true
if and only if the new thread was successfully started.
|
inlinestatic |
Causes the currently running thread to voluntarily relinquish the processor.
Another thread of equal or higher priority will be given a turn instead.