9#include <userver/engine/deadline.hpp>
10#include <userver/engine/impl/wait_list_fwd.hpp>
12USERVER_NAMESPACE_BEGIN
19class SingleConsumerEvent
final {
21 struct NoAutoReset
final {};
29 SingleConsumerEvent(
const SingleConsumerEvent&) =
delete;
30 SingleConsumerEvent(SingleConsumerEvent&&) =
delete;
31 SingleConsumerEvent& operator=(
const SingleConsumerEvent&) =
delete;
32 SingleConsumerEvent& operator=(SingleConsumerEvent&&) =
delete;
33 ~SingleConsumerEvent();
50 template <
typename Clock,
typename Duration>
51 [[nodiscard]]
bool WaitForEventFor(std::chrono::duration<Clock, Duration>);
54 template <
typename Clock,
typename Duration>
55 [[nodiscard]]
bool WaitForEventUntil(
56 std::chrono::time_point<Clock, Duration>);
59 [[nodiscard]]
bool WaitForEventUntil(Deadline);
76 [[nodiscard]]
bool IsReady()
const noexcept;
79 class EventWaitStrategy;
81 bool GetIsSignaled()
noexcept;
83 impl::FastPimplWaitListLight waiters_;
84 const bool is_auto_reset_{
true};
87template <
typename Clock,
typename Duration>
88bool SingleConsumerEvent::WaitForEventFor(
89 std::chrono::duration<Clock, Duration> duration) {
90 return WaitForEventUntil(Deadline::FromDuration(duration));
93template <
typename Clock,
typename Duration>
94bool SingleConsumerEvent::WaitForEventUntil(
95 std::chrono::time_point<Clock, Duration> time_point) {
96 return WaitForEventUntil(Deadline::FromTimePoint(time_point));