class Thread
Defined in:
The C4Threads.h
Thread
class encapsulates a thread of execution.
Definition
class Thread
Member Functions
Thread::GetThreadSignal |
Returns the signal associated with the thread. |
Thread::SetThreadSignal |
Sets the signal associated with the thread. |
Thread::SetThreadPriority |
Sets the priority of a thread. |
Thread::ThreadComplete |
Indicates whether a thread has completed execution. |
Constructor
Thread(ThreadCallback *callback, void *cookie, uint32 stack = 0, Signal *signal = nullptr);
Parameters
callback |
The entry point for the thread. |
cookie |
A pointer to user-defined data that is passed to the thread's entry point. |
stack |
The thread's stack size in bytes. If this is 0, then the default stack size is used. |
signal |
The signal object to assign to the thread. |
Description
The Thread
class defines a platform-independent thread object that can be used to achieve multithreaded execution. When a new Thread
object is constructed, the entry function specified by the callback
parameter begins executing immediately. The pointer passed into the cookie
parameter is passed to the thread's entry function, which must have the following signature.
typedef void ThreadCallback(const Thread *, void *);
stack
parameter is not zero, then it specifies the size of the stack allocated for the thread. Otherwise, the default stack size, as determined by the operating system, is used.If the
signal
parameter is not nullptr
, then it specifies a Signal
object that is assigned to the thread. When a Thread
object is destroyed and it has a Signal
object assigned to it, the thread triggers signal 0 to indicate that the thread should exit.
See Also