#include </opt/build/repo/nap/utility/src/utility/autoresetevent.h>
Public Types | |
enum | EWaitResult { Completed, Canceled } |
using | LockedWaitCallback = std::function< void(EWaitResult)> |
using | LockedSetCallback = std::function< void()> |
Public Member Functions | |
void | reset () |
EWaitResult | wait (const LockedWaitCallback &callback=LockedWaitCallback()) |
void | set (const LockedSetCallback &callback=LockedSetCallback()) |
void | cancelWait () |
Helper class that implements an AutoResetEvent on top of condition_variable. You can use this to wait for an event to happen; once the wait completes, the event is reset and you can wait on the event again. If the event is set before the wait is entered, the wait completes immediately and resets the event.
using LockedSetCallback = std::function<void()> |
using LockedWaitCallback = std::function<void(EWaitResult)> |
|
strong |
void cancelWait | ( | ) |
If any threads are waiting on the event, cancel their waits
void reset | ( | ) |
Resets the event to a non-signaled, non-canceled state
void set | ( | const LockedSetCallback & | callback = LockedSetCallback() | ) |
Signal the event, unblocking any threads waiting on it
callback | An optional callback that is called when the set completes. This callback has the special property that it is executed during the same lock as the wait() function. This makes the code executing in the callback effectively an 'atomic' operation with the set. |
EWaitResult wait | ( | const LockedWaitCallback & | callback = LockedWaitCallback() | ) |
Wait for the event to be signaled. This is an infinite wait, which can be canceled by calling cancelWait()
callback | An optional callback that is called when the wait completes. This callback has the special property that it is executed during the same lock as the set() function. This makes the code executing in the callback effectively an 'atomic' operation with the wait. |