The thread base class. More...
#include "murl_system_thread.h"
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... | |
virtual UInt64 | GetId () |
Get the thread identifier. 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. | |
String | mName |
The name of the thread. | |
UInt64 | mThreadId |
The identifier of the thread. | |
ThreadHandle * | mHandle |
The anonymous thread handle for internal use only. | |
Detailed Description
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.
Member Enumeration Documentation
◆ SchedulingPriority
Thread scheduling priority enumeration.
Enumerator | |
---|---|
SCHEDULING_PRIORITY_LOWEST | Lowest priority. |
SCHEDULING_PRIORITY_NORMAL | Normal priority. |
SCHEDULING_PRIORITY_HIGHEST | Highest priority. |
◆ SchedulingPolicy
Thread scheduling policy enumeration.
Enumerator | |
---|---|
SCHEDULING_POLICY_OTHER | Unspecified policy. |
SCHEDULING_POLICY_FIFO | FIFO policy. |
SCHEDULING_POLICY_ROUND_ROBIN | Round robin policy. |
Constructor & Destructor Documentation
◆ Thread()
|
protected |
Constructor taking a thread name.
- Parameters
-
name The name of the thread. On OSX/iOS systems the thread name is truncated to 63 characters.
Member Function Documentation
◆ Start()
|
virtual |
Create and start the thread.
Set the mIsRunning state to true.
- Returns
- true if successful, false if starting failed or the thread is already created.
Reimplemented in Murl::Util::MessageThread.
◆ Stop()
|
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.
◆ Join()
|
virtual |
◆ Flush()
|
virtual |
Flush the autorelease memory pool.
Drain the AutoReleasePool on OSX/iOS systems.
◆ GetId()
|
virtual |
Get the thread identifier.
Directly after creation, the thread's identifier remains unknown until Start() is called. Only then a valid identifier is returned.
- Returns
- The thread identifier, or 0 if the thread has not been started yet.
◆ SetCurrentPriority()
|
static |
Set the current thread's priority and scheduling policy.
- Parameters
-
priority One of the available thread priority enum values. policy A hint to the scheduling policy to use.
- Returns
- true if successful.
◆ SetCurrentAffinityMask()
Set the current thread's CPU affinity mask.
- Parameters
-
mask A bit mask representing individual CPUs (or CPU cores)
- Returns
- true if successful.
◆ GetCurrentId()
|
static |
Get the current thread identifier.
The current thread identifier is not necessarily the identifier of the thread class. Note the static declaration which means System::Thread::GetCurrentId() can be called without a class context.
- Returns
- The current thread identifier.
◆ Run()
|
protectedpure virtual |
The abstract run method for overloading.
On OSX/iOS systems an AutoReleasePool is created before calling Run().
- Returns
- true if successful.
Implemented in Murl::Util::MessageThread.
The documentation for this class was generated from the following file:
- murl_system_thread.h