CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::AsyncAutoResetEvent Class Reference

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< UInt64mState
 
Atomic< Operation * > mNewWaiters
 
OperationmWaiters
 

Friends

class Operation
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AsyncAutoResetEvent()

CeresEngine::AsyncAutoResetEvent::AsyncAutoResetEvent ( bool  initiallySet = false)
noexcept

Initialise the event to either 'set' or 'not set' state.

◆ ~AsyncAutoResetEvent()

CeresEngine::AsyncAutoResetEvent::~AsyncAutoResetEvent ( )

Member Function Documentation

◆ operator co_await()

Operation CeresEngine::AsyncAutoResetEvent::operator co_await ( ) const
noexcept

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()'.

◆ reset()

void CeresEngine::AsyncAutoResetEvent::reset ( )
noexcept

Set the state of the event to 'not-set'.

This is a no-op if the state was already 'not set'.

◆ resume_waiters()

void CeresEngine::AsyncAutoResetEvent::resume_waiters ( UInt64  initialState) const
privatenoexcept

◆ set()

void CeresEngine::AsyncAutoResetEvent::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'.

Friends And Related Symbol Documentation

◆ Operation

Member Data Documentation

◆ mNewWaiters

Atomic<Operation*> CeresEngine::AsyncAutoResetEvent::mNewWaiters
mutableprivate

◆ mState

Atomic<UInt64> CeresEngine::AsyncAutoResetEvent::mState
mutableprivate

◆ mWaiters

Operation* CeresEngine::AsyncAutoResetEvent::mWaiters
mutableprivate

The documentation for this class was generated from the following file: