Github   Telegram
No Matches
Classes | Public Member Functions | List of all members
engine::SingleConsumerEvent Class Referencefinal

A multiple-producers, single-consumer event. More...

#include <userver/engine/single_consumer_event.hpp>


struct  NoAutoReset

Public Member Functions

 SingleConsumerEvent () noexcept
 Creates an event that resets automatically on retrieval.
 SingleConsumerEvent (NoAutoReset) noexcept
 Creates an event that does not reset automatically.
 SingleConsumerEvent (const SingleConsumerEvent &)=delete
 SingleConsumerEvent (SingleConsumerEvent &&)=delete
SingleConsumerEventoperator= (const SingleConsumerEvent &)=delete
SingleConsumerEventoperator= (SingleConsumerEvent &&)=delete
bool IsAutoReset () const noexcept
bool WaitForEvent ()
 Waits until the event is in a signaled state.
template<typename Clock , typename Duration >
bool WaitForEventFor (std::chrono::duration< Clock, Duration >)
template<typename Clock , typename Duration >
bool WaitForEventUntil (std::chrono::time_point< Clock, Duration >)
bool WaitForEventUntil (Deadline)
void Reset () noexcept
void Send ()
bool IsReady () const noexcept
 Returns true iff already signaled. Never resets the signal.

Detailed Description

A multiple-producers, single-consumer event.

Definition at line 19 of file single_consumer_event.hpp.

Member Function Documentation

◆ IsAutoReset()

bool engine::SingleConsumerEvent::IsAutoReset ( ) const
whether this event resets automatically on retrieval

◆ Reset()

void engine::SingleConsumerEvent::Reset ( )

Resets the signal flag. Guarantees at least 'acquire' and 'release' memory ordering.

◆ 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.

◆ 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.

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)

Definition at line 83 of file single_consumer_event.hpp.

◆ WaitForEventUntil()

template<typename Clock , typename Duration >
bool engine::SingleConsumerEvent::WaitForEventUntil ( std::chrono::time_point< Clock, Duration >  time_point)

Definition at line 89 of file single_consumer_event.hpp.

The documentation for this class was generated from the following file: