A single-producer, single-consumer event. More...
#include <userver/engine/single_use_event.hpp>
Public Member Functions | |
| SingleUseEvent (const SingleUseEvent &)=delete | |
| SingleUseEvent (SingleUseEvent &&)=delete | |
| SingleUseEvent & | operator= (const SingleUseEvent &)=delete |
| SingleUseEvent & | operator= (SingleUseEvent &&)=delete |
| void | WaitNonCancellable () noexcept |
| Waits until the event is in a signaled state. | |
| void | Send () noexcept |
| void | Reset () noexcept |
| bool | IsReady () const noexcept |
| Returns true iff already signaled. Never resets the signal. | |
A single-producer, single-consumer event.
Must not be awaited or signaled multiple times in the same waiting session.
The main advantage of SingleUseEvent over SingleConsumerEvent is that the waiting coroutine is allowed to immediately destroy the SingleUseEvent after waking up; it will not stop a concurrent Send from completing correctly.
Timeouts and cancellations are not supported. Only a concurrent call to Send can wake up the waiter. This is necessary for the waiter not to destroy the SingleUseEvent unexpectedly for the sender.
Definition at line 33 of file single_use_event.hpp.
|
inlineconstexprnoexcept |
Definition at line 35 of file single_use_event.hpp.
|
noexcept |
Resets the signal flag. Can be called after WaitNonCancellable returns if necessary to reuse the SingleUseEvent for another waiting session.
|
noexcept |
Sets the signal flag and wakes a coroutine that waits on it, if any. Send must not be called again without Reset.
|
noexcept |
Waits until the event is in a signaled state.
The event then remains in a signaled state, it does not reset automatically.
The waiter coroutine can destroy the SingleUseEvent object immediately after waking up, if necessary.