Plasma Engine  2.0
Loading...
Searching...
No Matches
ThreadWithDispatcher.h
1#pragma once
2
3#include <Foundation/Basics.h>
4#include <Foundation/Threading/Thread.h>
5
10class PL_FOUNDATION_DLL plThreadWithDispatcher : public plThread
11{
12public:
13 using DispatchFunction = plDelegate<void(), 128>;
14
16 plThreadWithDispatcher(const char* szName = "plThreadWithDispatcher", plUInt32 uiStackSize = 128 * 1024);
17
20
22 void Dispatch(DispatchFunction&& delegate);
23
24protected:
26 void DispatchQueue();
27
28private:
30 virtual plUInt32 Run() = 0;
31
33 plDynamicArray<DispatchFunction> m_CurrentlyBeingDispatchedQueue;
34
35 plMutex m_QueueMutex;
36};
Definition DynamicArray.h:81
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13
This class is the base class for platform independent long running threads.
Definition Thread.h:40
This class is the base class for threads which need dispatching of calls.
Definition ThreadWithDispatcher.h:11
virtual plUInt32 Run()=0
The run function can be used to implement a long running task in a thread in a platform independent w...
virtual ~plThreadWithDispatcher()
Destructor checks if the thread is deleted while still running, which is not allowed as this is a dat...
A generic delegate class which supports static functions and member functions.
Definition Delegate.h:76