37 bool Ready()
noexcept;
49 template <
typename Rep,
typename Period>
58 template <
typename Clock,
typename Duration>
66 explicit BaseAwaiter(
OneShotEvent& event) noexcept : _event{
event} {
69 constexpr void await_resume() const noexcept {
77 using BaseAwaiter::BaseAwaiter;
80 void Call() noexcept final {
81 _core->_executor->Submit(*_core);
86 detail::BaseCore* _core;
92 using BaseAwaiter::BaseAwaiter;
94 YACLIB_INLINE
bool await_ready() const noexcept {
95 return _event.Ready();
98 template <
typename Promise>
99 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
100 return _event.TryAdd(handle.promise());
106 using ExtendedAwaiter::ExtendedAwaiter;
108 YACLIB_INLINE
bool await_ready() const noexcept {
109 return _event.Ready();
112 template <
typename Promise>
113 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
114 _core = &handle.promise();
115 return _event.TryAdd(*
this);
121 explicit OnAwaiter(OneShotEvent& event, IExecutor& executor) noexcept : ExtendedAwaiter{
event} {
122 _executor = &executor;
125 constexpr bool await_ready() const noexcept {
129 template <
typename Promise>
130 YACLIB_INLINE
void await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
131 auto& core = handle.promise();
132 core._executor = _executor;
134 if (!_event.TryAdd(*
this)) {
230 template <
typename Timeout>
231 bool TimedWait(
const Timeout&
timeout) {
241 static constexpr auto kEmpty = std::uintptr_t{0};
242 static constexpr auto kAllDone = std::numeric_limits<std::uintptr_t>::max();
virtual void DecRef() noexcept
Decrements reference counter.
Callable that can be executed in an IExecutor.
This class useful to wait or co_await some event.
void Set() noexcept
Prevent pushing new jobs and Call()
void Call() noexcept
Get all jobs and Call them.
bool TryAdd(Job &job) noexcept
Add job to the MPSC event queue.
YACLIB_INLINE bool WaitUntil(const std::chrono::time_point< Clock, Duration > &timeout_time)
WaitUntil Call or Set immediately return if Event is Ready.
void Wait() noexcept
Wait Call or Set immediately return if Event is Ready.
bool Ready() noexcept
was or not Set
YACLIB_INLINE bool WaitFor(const std::chrono::duration< Rep, Period > &timeout_duration)
WaitFor Call or Set immediately return if Event is Ready.
void Reset() noexcept
Reinitializes OneShotEvent, semantically the same as *this = {};
atomic< std::uintptr_t > atomic_uintptr_t
YACLIB_INLINE auto AwaitInline(Waited &waited) noexcept
YACLIB_INLINE auto AwaitOn(IExecutor &e, Waited &waited) noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
YACLIB_INLINE auto AwaitSticky(Waited &waited) noexcept
Public only because Waiter is public.
void Call() noexcept final
Waiter is public for advanced users.
void Call() noexcept final