178 void*
oldValue =
mState.exchange(
this, std::memory_order_release);
190 (
void)
mState.exchange(
nullptr, std::memory_order_acquire);
202 [[nodiscard]]
bool await_ready()
const noexcept {
return false; }
203 [[nodiscard]]
bool await_suspend(
const CoroutineHandle<> awaitingCoroutine)
noexcept {
204 mAwaitingCoroutine = awaitingCoroutine;
206 void* oldValue =
nullptr;
207 if(!mEvent.mState.compare_exchange_strong(oldValue, &mAwaitingCoroutine, std::memory_order_release, std::memory_order_relaxed)) {
214 (void)mEvent.mState.exchange(
nullptr, std::memory_order_acquire);
221 void await_resume()
noexcept {}
294 [[nodiscard]]
bool await_ready()
const noexcept {
return mEvent.is_set(); }
296 mEvent.mAwaiter = awaiter;
298 state oldState = state::not_set;
299 return mEvent.mState.compare_exchange_strong(oldState, state::not_set_consumer_waiting, std::memory_order_release, std::memory_order_acquire);
302 void await_resume()
noexcept {}
#define CE_ASSERT(...)
Definition Macros.hpp:323
Definition AsyncEvent.hpp:141
bool await_suspend(CoroutineHandle<> awaiter) noexcept
void await_resume() const noexcept
Definition AsyncEvent.hpp:150
CoroutineHandle mAwaiter
Definition AsyncEvent.hpp:157
Atomic< UInt32 > mRefCount
Definition AsyncEvent.hpp:158
const AsyncAutoResetEvent * mEvent
Definition AsyncEvent.hpp:155
Operation * mNext
Definition AsyncEvent.hpp:156
An async auto-reset event is a coroutine synchronisation abstraction that allows one or more coroutin...
Definition AsyncEvent.hpp:106
Operation * mWaiters
Definition AsyncEvent.hpp:170
AsyncAutoResetEvent(bool initiallySet=false) noexcept
Initialise the event to either 'set' or 'not set' state.
void resume_waiters(UInt64 initialState) const noexcept
Atomic< UInt64 > mState
Definition AsyncEvent.hpp:168
void set() noexcept
Set the state of the event to 'set'.
Atomic< Operation * > mNewWaiters
Definition AsyncEvent.hpp:169
void reset() noexcept
Set the state of the event to 'not-set'.
Definition AsyncEvent.hpp:72
const AsyncManualResetEvent & mEvent
Definition AsyncEvent.hpp:83
CoroutineHandle mAwaiter
Definition AsyncEvent.hpp:85
bool await_ready() const noexcept
Operation * mNext
Definition AsyncEvent.hpp:84
Operation(const AsyncManualResetEvent &event) noexcept
An async manual-reset event is a coroutine synchronisation abstraction that allows one or more corout...
Definition AsyncEvent.hpp:27
void reset() noexcept
Set the state of the event to 'not-set'.
Atomic< void * > mState
Definition AsyncEvent.hpp:97
AsyncManualResetEvent(bool initiallySet=false) noexcept
Initialise the event to either 'set' or 'not set' state.
bool isSet() const noexcept
Query if the event is currently in the 'set' state.
void set() noexcept
Set the state of the event to 'set'.
Definition AsyncEvent.hpp:173
void set() noexcept
Definition AsyncEvent.hpp:177
Atomic< void * > mState
Definition AsyncEvent.hpp:235
SingleConsumerAsyncAutoResetEvent(const bool initiallySet=false) noexcept
Definition AsyncEvent.hpp:175
A manual-reset event that supports only a single awaiting coroutine at a time.
Definition AsyncEvent.hpp:250
state
Definition AsyncEvent.hpp:312
@ not_set_consumer_waiting
Atomic< state > mState
Definition AsyncEvent.hpp:321
CoroutineHandle mAwaiter
Definition AsyncEvent.hpp:322
SingleConsumerEvent(const bool initiallySet=false) noexcept
Construct a new event, initialising to either 'set' or 'not set' state.
Definition AsyncEvent.hpp:258
void set()
Transition this event to the 'set' state if it is not already set.
Definition AsyncEvent.hpp:268
bool is_set() const noexcept
Query if this event has been set.
Definition AsyncEvent.hpp:261
void reset() noexcept
Transition this event to the 'non set' state if it was in the set state.
Definition AsyncEvent.hpp:277
Definition Application.hpp:19
std::uint64_t UInt64
Definition DataTypes.hpp:26
std::coroutine_handle< T > CoroutineHandle
A type alias to the C++ standard library coroutine handle.
Definition Coroutine.hpp:26
std::atomic< T > Atomic
The Atomic template defines an atomic type.
Definition Atomic.hpp:16
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25