Plasma Engine  2.0
Loading...
Searching...
No Matches
ThreadSignal.h
1#pragma once
2
3#include <Foundation/Basics.h>
4#include <Foundation/Threading/ConditionVariable.h>
5
18class PL_FOUNDATION_DLL plThreadSignal
19{
20 PL_DISALLOW_COPY_AND_ASSIGN(plThreadSignal);
21
22public:
23 enum class Mode
24 {
25 AutoReset,
26 ManualReset
27 };
28
29 enum class WaitResult
30 {
31 Signaled,
32 Timeout
33 };
34
35 plThreadSignal(Mode mode = Mode::AutoReset);
37
41 void WaitForSignal() const;
42
46 WaitResult WaitForSignal(plTime timeout) const;
47
58 void RaiseSignal();
59
61 void ClearSignal();
62
63private:
64 Mode m_Mode = Mode::AutoReset;
65 mutable bool m_bSignalState = false;
66 mutable plConditionVariable m_ConditionVariable;
67};
Condition variables are used to put threads to sleep and wake them up upon certain events.
Definition ConditionVariable.h:22
Waiting on a thread signal puts the waiting thread to sleep. Other threads can wake it up by raising ...
Definition ThreadSignal.h:19
Mode
Definition ThreadSignal.h:24
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12