A multiple-producers, single-consumer event.
More...
#include <userver/engine/single_consumer_event.hpp >
A multiple-producers, single-consumer event.
Definition at line 19 of file single_consumer_event.hpp .
◆ IsAutoReset()
bool engine::SingleConsumerEvent::IsAutoReset
(
)
const
noexcept
Returns whether this event resets automatically on retrieval
◆ Reset()
void engine::SingleConsumerEvent::Reset
(
)
noexcept
Resets the signal flag. Guarantees at least 'acquire' and 'release' memory ordering. Must only be called by the waiting task.
◆ Send()
void engine::SingleConsumerEvent::Send
(
)
Sets the signal flag and wakes a coroutine that waits on it (if any). If the signal flag is already set, does nothing.
The waiter is allowed to destroy the SingleConsumerEvent immediately after exiting WaitForEvent, ONLY IF the wait succeeded. Otherwise a concurrent task may call Send on a destroyed SingleConsumerEvent . Here is an example of this situation:
{
const bool success = event .WaitForEvent();
if (!success) {
}
}
◆ WaitForEvent()
bool engine::SingleConsumerEvent::WaitForEvent
(
)
Waits until the event is in a signaled state.
If the event is auto-resetting, clears the signal flag upon waking up. If already in a signaled state, does the same without sleeping.
If we the waiting failed (the event did not signal), because the optional deadline is expired or the current task is cancelled, returns false
.
Returns whether the event signaled
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ WaitForEventFor()
template<typename Clock , typename Duration >
bool engine::SingleConsumerEvent::WaitForEventFor
(
std::chrono::duration< Clock, Duration >
duration )
◆ WaitForEventUntil()
template<typename Clock , typename Duration >
bool engine::SingleConsumerEvent::WaitForEventUntil
(
std::chrono::time_point< Clock, Duration >
time_point )
The documentation for this class was generated from the following file: