![]() |
Murl Engine API
Version 2018.3
|
The thread base class. More...
#include <murl_system_thread.h>
The thread base class.
The implementation of a thread class must derive from the thread base class and implement the Run() method.
(!) Important: To avoid destroying the thread object while the thread is running, it is required to implement the destructor.
Public Types | |
enum | SchedulingPriority { SCHEDULING_PRIORITY_LOWEST, SCHEDULING_PRIORITY_NORMAL, SCHEDULING_PRIORITY_HIGHEST } |
Thread scheduling priority enumeration. More... | |
enum | SchedulingPolicy { SCHEDULING_POLICY_OTHER, SCHEDULING_POLICY_FIFO, SCHEDULING_POLICY_ROUND_ROBIN } |
Thread scheduling policy enumeration. More... | |
Public Member Functions | |
virtual | ~Thread () |
The destructor. | |
virtual Bool | Start () |
Create and start the thread. More... | |
virtual void | Stop () |
Stop the thread. More... | |
virtual void | Join () |
Join and destroy the thread. More... | |
virtual void | Flush () |
Flush the autorelease memory pool. More... | |
Static Public Member Functions | |
static Bool | SetCurrentPriority (SchedulingPriority priority, SchedulingPolicy policy=SCHEDULING_POLICY_OTHER) |
Set the current thread's priority and scheduling policy. More... | |
static Bool | SetCurrentAffinityMask (UInt32 mask) |
Set the current thread's CPU affinity mask. More... | |
static UInt64 | GetCurrentId () |
Get the current thread identifier. More... | |
Protected Member Functions | |
Thread (const String &name) | |
Constructor taking a thread name. More... | |
virtual Bool | Run ()=0 |
The abstract run method for overloading. More... | |
Protected Attributes | |
Bool | mIsRunning |
The running state of the thread. More... | |
String | mName |
The name of the thread. More... | |
UInt64 | mThreadId |
The identifier of the thread. More... | |
ThreadHandle * | mHandle |
The anonymous thread handle for internal use only. More... | |
Thread scheduling priority enumeration.
Enumerator | |
---|---|
SCHEDULING_PRIORITY_LOWEST | Lowest priority. |
SCHEDULING_PRIORITY_NORMAL | Normal priority. |
SCHEDULING_PRIORITY_HIGHEST | Highest priority. |
Thread scheduling policy enumeration.
Enumerator | |
---|---|
SCHEDULING_POLICY_OTHER | Unspecified policy. |
SCHEDULING_POLICY_FIFO | FIFO policy. |
SCHEDULING_POLICY_ROUND_ROBIN | Round robin policy. |
|
protected |
Constructor taking a thread name.
name | The name of the thread. On OSX/iOS systems the thread name is truncated to 63 characters. |
|
virtual |
Create and start the thread.
Set the mIsRunning state to true.
Reimplemented in Murl::Util::MessageThread.
|
virtual |
Stop the thread.
Set the mIsRunning state to false. After calling Stop() it is required to call Join(), otherwise it is not possible to call Start() again.
Reimplemented in Murl::Util::MessageThread.
|
virtual |
|
virtual |
Flush the autorelease memory pool.
Drain the AutoReleasePool on OSX/iOS systems.
|
static |
Set the current thread's priority and scheduling policy.
priority | One of the available thread priority enum values. |
policy | A hint to the scheduling policy to use. |
Set the current thread's CPU affinity mask.
mask | A bit mask representing individual CPUs (or CPU cores) |
|
static |
Get the current thread identifier.
The current thread identifier is not necessarily the identifier of the thread class, notify the static declaration which means System::Thread::GetCurrentId() can be called without a class context.
|
protectedpure virtual |
The abstract run method for overloading.
On OSX/iOS systems an AutoReleasePool is created before calling Run().
Implemented in Murl::Util::MessageThread.
|
protected |
The running state of the thread.
|
protected |
The name of the thread.
|
protected |
The identifier of the thread.
|
protected |
The anonymous thread handle for internal use only.