This class is the base class for threads which need dispatching of calls.
More...
#include <ThreadWithDispatcher.h>
|
using | DispatchFunction = plDelegate<void(), 128> |
|
enum | plThreadStatus { Created = 0
, Running
, Finished
} |
| Describes the thread status.
|
|
|
| plThreadWithDispatcher (const char *szName="plThreadWithDispatcher", plUInt32 uiStackSize=128 *1024) |
| Initializes the runnable class.
|
|
virtual | ~plThreadWithDispatcher () |
| Destructor checks if the thread is deleted while still running, which is not allowed as this is a data hazard.
|
|
void | Dispatch (DispatchFunction &&delegate) |
| Use this to enqueue a function call to the given delegate at some later point running in the given thread context.
|
|
| plThread (plStringView sName="plThread", plUInt32 uiStackSize=128 *1024) |
| Initializes the runnable class.
|
|
virtual | ~plThread () |
| Destructor checks if the thread is deleted while still running, which is not allowed as this is a data hazard.
|
|
plThreadStatus | GetThreadStatus () const |
| Returns the thread status.
|
|
bool | IsRunning () const |
| Helper function to determine if the thread is running.
|
|
const char * | GetThreadName () const |
| Returns the thread name.
|
|
| plOSThread (plOSThreadEntryPoint threadEntryPoint, void *pUserData=nullptr, plStringView sName="plOSThread", plUInt32 uiStackSize=128 *1024) |
| Initializes the thread instance (e.g. thread creation etc.)
|
|
virtual | ~plOSThread () |
| Destructor.
|
|
void | Start () |
| Starts the thread.
|
|
void | Join () |
| Waits in the calling thread until the thread has finished execution (e.g. returned from the thread function)
|
|
const plThreadID & | GetThreadID () const |
| Returns the thread ID of the thread object, may be used in comparison operations with plThreadUtils::GetCurrentThreadID() for example.
|
|
|
void | DispatchQueue () |
| Needs to be called by derived thread implementations to dispatch the function calls.
|
|
|
virtual plUInt32 | Run ()=0 |
| The run function can be used to implement a long running task in a thread in a platform independent way.
|
|
|
static const plThread * | GetCurrentThread () |
| Returns the current plThread if the current platform thread is an plThread. Returns nullptr otherwise.
|
|
static plInt32 | GetThreadCount () |
| Returns how many plOSThreads are currently active.
|
|
static plEvent< const plThreadEvent &, plMutex > | s_ThreadEvents |
| These events inform about threads starting and finishing.
|
|
plThreadHandle | m_hHandle |
|
plThreadID | m_ThreadID |
|
plOSThreadEntryPoint | m_EntryPoint |
|
void * | m_pUserData |
|
plString | m_sName |
|
plUInt32 | m_uiStackSize |
|
This class is the base class for threads which need dispatching of calls.
Used by deriving from this class and overriding the Run() method. Call DispatchQueue() regurarely so that the collected messages can be dispatched.
◆ Run()
virtual plUInt32 plThreadWithDispatcher::Run |
( |
| ) |
|
|
privatepure virtual |
The run function can be used to implement a long running task in a thread in a platform independent way.
Implements plThread.
The documentation for this class was generated from the following files:
- Code/Engine/Foundation/Threading/ThreadWithDispatcher.h
- Code/Engine/Foundation/Threading/Implementation/ThreadWithDispatcher.cpp