#include <userver/engine/pulse_event.hpp>
A multiple-producers, multiple-consumers notification.
Subscribe issues a one-shot PulseEventSubscription. Any Send after that satisfies it; a Send that happened before Subscribe does not count. After that first Send, the subscription stays ready; call Subscribe again to wait for later signals.
This is unlike engine::MultiConsumerEvent, which latches a single global signal forever after the first Send (equivalent to engine::SingleConsumerEvent::NoAutoReset).
PulseEventSubscription is compatible with engine::WaitAny and friends. PulseEvent itself is not an awaitable: wait on a subscription from Subscribe.
Definition at line 92 of file pulse_event.hpp.
Public Member Functions | |
| PulseEvent (const PulseEvent &)=delete | |
| PulseEvent (PulseEvent &&)=delete | |
| PulseEvent & | operator= (const PulseEvent &)=delete |
| PulseEvent & | operator= (PulseEvent &&)=delete |
| PulseEventSubscription | Subscribe () noexcept |
| Issues a one-shot subscription that later Send calls can satisfy. | |
| template<typename Predicate> | |
| FutureStatus | WaitUntil (Deadline, Predicate stop_waiting) |
| Works like std::condition_variable::wait_until. Waits until stop_waiting becomes true, and we are notified via Send. | |
| void | Send () noexcept |
|
noexcept |
|
nodiscard |
Works like std::condition_variable::wait_until. Waits until stop_waiting becomes true, and we are notified via Send.
If stop_waiting is already true, returns right away.
Unlike std::condition_variable and engine::ConditionVariable, there are no locks around the state watched by stop_waiting, so that state must be atomic. std::memory_order_relaxed is OK inside stop_waiting and inside the notifiers as long as it does not mess up their logic.
For a full example, see engine_pulse_event.
Definition at line 137 of file pulse_event.hpp.
|
friend |
Definition at line 130 of file pulse_event.hpp.