#include <WaitableEvent.h>
Public Types | |
enum class | WaitStatus |
Public Member Functions | |
~WaitableEvent ()=default | |
nonvirtual void | Reset () |
nonvirtual bool | GetIsSet () const noexcept |
nonvirtual bool | PeekIsSet () const noexcept |
nonvirtual void | Set () |
nonvirtual void | Wait (Time::DurationSeconds timeout=Time::kInfinity) |
nonvirtual WaitStatus | WaitQuietly (Time::DurationSeconds timeout=Time::kInfinity) |
nonvirtual void | WaitUntil (Time::TimePointSeconds timeoutAt) |
nonvirtual WaitStatus | WaitUntilQuietly (Time::TimePointSeconds timeoutAt) |
nonvirtual void | WaitAndReset (Time::Duration timeout=Time::kInfinity) |
AutoReset Waitable Event (like Windows' CreateEvent (resetType==eManualReset, false)).
Definition at line 80 of file WaitableEvent.h.
|
strong |
Intentionally omit case of spurious wakeup we get from condition variables.
Definition at line 166 of file WaitableEvent.h.
|
default |
void Stroika::Foundation::Execution::WaitableEvent::Reset | ( | ) |
Set the event to the non-signaled state
Definition at line 50 of file WaitableEvent.inl.
|
noexcept |
This checks if the event is currently in a triggered state. Regardless of the type of event (auto-reset or not) - this does not change the trigger state.
Definition at line 55 of file WaitableEvent.inl.
|
noexcept |
This checks if the event is currently in a triggered state. Regardless of the type of event (auto-reset or not) - this does not change the trigger state.
Because of this - if testing with TSAN (thread sanitizer) - probably best to prefix functions calling this with Stroika_Foundation_Debug_ATTRIBUTE_NO_SANITIZE_THREAD
Definition at line 59 of file WaitableEvent.inl.
void WaitableEvent::Set | ( | ) |
Set the event to the signaled state.
Definition at line 96 of file WaitableEvent.cpp.
void Stroika::Foundation::Execution::WaitableEvent::Wait | ( | Time::DurationSeconds | timeout = Time::kInfinity | ) |
Simple wait. Can use operator HANDLE() to do fancier waits. timeout can be negative (which triggers an immediate exception).
TimeOutException throws if the timeout is exceeeded.
Definition at line 63 of file WaitableEvent.inl.
auto Stroika::Foundation::Execution::WaitableEvent::WaitQuietly | ( | Time::DurationSeconds | timeout = Time::kInfinity | ) |
Wait the given period of time, and return true if event occurred (Set called), and false on timeout. This is mostly useful if we want a wait, for advisory purposes (say to avoid races), but don't want an exception as its not an issue to handle specially.
Returns: true (kWaitQuietlySetResult) if event signaled/occurred, and false (kWaitQuietlyTimeoutResult) if timeout
Definition at line 67 of file WaitableEvent.inl.
void Stroika::Foundation::Execution::WaitableEvent::WaitUntil | ( | Time::TimePointSeconds | timeoutAt | ) |
TimeOutException throws if the event is not signaled before timeoutAt is exceeded (includes when reached).
Definition at line 71 of file WaitableEvent.inl.
auto Stroika::Foundation::Execution::WaitableEvent::WaitUntilQuietly | ( | Time::TimePointSeconds | timeoutAt | ) |
Returns: true (kWaitQuietlySetResult) if event signaled/occurred, and false (kWaitQuietlyTimeoutResult) if timeout
Note - unlike condition variable - will not return with spurious wakeup. So a return of triggered means it definitely was triggered!
Definition at line 75 of file WaitableEvent.inl.
void Stroika::Foundation::Execution::WaitableEvent::WaitAndReset | ( | Time::Duration | timeout = Time::kInfinity | ) |
Unclear if this is a good idea. Its a preplacement for 'auto-reset' events in Stroika v2.1.
Definition at line 79 of file WaitableEvent.inl.