|
CeresEngine 0.2.0
A game development framework
|
A manual-reset event that supports only a single awaiting coroutine at a time. More...
#include <CeresEngine/Foundation/Threading/AsyncEvent.hpp>
Public Member Functions | |
| SingleConsumerEvent (const bool initiallySet=false) noexcept | |
| Construct a new event, initialising to either 'set' or 'not set' state. | |
| bool | is_set () const noexcept |
| Query if this event has been set. | |
| void | set () |
| Transition this event to the 'set' state if it is not already set. | |
| void | reset () noexcept |
| Transition this event to the 'non set' state if it was in the set state. | |
| auto | operator co_await () noexcept |
| Wait until the event becomes set. | |
Private Types | |
| enum class | state { not_set , not_set_consumer_waiting , set } |
Private Attributes | |
| Atomic< state > | mState |
| CoroutineHandle | mAwaiter |
A manual-reset event that supports only a single awaiting coroutine at a time.
You can co_await the event to suspend the current coroutine until some thread calls set(). If the event is already set then the coroutine will not be suspended and will continue execution. If the event was not yet set then the coroutine will be resumed on the thread that calls set() within the call to set().
Callers must ensure that only one coroutine is executing a co_await statement at any point in time.
|
strongprivate |
|
inlinenoexcept |
Construct a new event, initialising to either 'set' or 'not set' state.
| initiallySet | If true then initialises the event to the 'set' state. Otherwise, initialised the event to the 'not set' state. |
|
inlinenoexcept |
Query if this event has been set.
|
inlinenoexcept |
Transition this event to the 'non set' state if it was in the set state.
|
inline |
Transition this event to the 'set' state if it is not already set.
If there was a coroutine awaiting the event then it will be resumed inside this call.
|
private |