|
CeresEngine 0.2.0
A game development framework
|
An async auto-reset event is a coroutine synchronisation abstraction that allows one or more coroutines to wait until some thread calls set() on the event. More...
#include <CeresEngine/Foundation/Threading/AsyncEvent.hpp>
Classes | |
| class | Operation |
Public Member Functions | |
| AsyncAutoResetEvent (bool initiallySet=false) noexcept | |
| Initialise the event to either 'set' or 'not set' state. | |
| ~AsyncAutoResetEvent () | |
| Operation | operator co_await () const noexcept |
| Wait for the event to enter the 'set' state. | |
| void | set () noexcept |
| Set the state of the event to 'set'. | |
| void | reset () noexcept |
| Set the state of the event to 'not-set'. | |
Private Member Functions | |
| void | resume_waiters (UInt64 initialState) const noexcept |
Private Attributes | |
| Atomic< UInt64 > | mState |
| Atomic< Operation * > | mNewWaiters |
| Operation * | mWaiters |
Friends | |
| class | Operation |
An async auto-reset event is a coroutine synchronisation abstraction that allows one or more coroutines to wait until some thread calls set() on the event.
When a coroutine awaits a 'set' event the event is automatically reset back to the 'not set' state, thus the name 'auto reset' event.
Initialise the event to either 'set' or 'not set' state.
| CeresEngine::AsyncAutoResetEvent::~AsyncAutoResetEvent | ( | ) |
Wait for the event to enter the 'set' state.
If the event is already 'set' then the event is set to the 'not set' state and the awaiting coroutine continues without suspending. Otherwise, the coroutine is suspended and later resumed when some thread calls 'set()'.
Note that the coroutine may be resumed inside a call to 'set()' or inside another thread's call to 'operator co_await()'.
|
noexcept |
Set the state of the event to 'not-set'.
This is a no-op if the state was already 'not set'.
|
noexcept |
Set the state of the event to 'set'.
If there are pending coroutines awaiting the event then one pending coroutine is resumed and the state is immediately set back to the 'not set' state.
This operation is a no-op if the event was already 'set'.
|
mutableprivate |