41 bool Ready()
noexcept;
53 template <
typename Rep,
typename Period>
62 template <
typename Clock,
typename Duration>
70 explicit BaseAwaiter(
OneShotEvent& event) noexcept : _event{
event} {
73 constexpr void await_resume() const noexcept {
81 using BaseAwaiter::BaseAwaiter;
84 void Call() noexcept final {
85 _core->_executor->Submit(*_core);
90 detail::BaseCore* _core;
96 using BaseAwaiter::BaseAwaiter;
98 YACLIB_INLINE
bool await_ready() const noexcept {
99 return _event.Ready();
102 template <
typename Promise>
103 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
104 return _event.TryAdd(handle.promise());
110 using ExtendedAwaiter::ExtendedAwaiter;
112 YACLIB_INLINE
bool await_ready() const noexcept {
113 return _event.Ready();
116 template <
typename Promise>
117 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
118 _core = &handle.promise();
119 return _event.TryAdd(*
this);
125 explicit OnAwaiter(OneShotEvent& event, IExecutor& executor) noexcept : ExtendedAwaiter{
event} {
126 _executor = &executor;
129 constexpr bool await_ready() const noexcept {
133 template <
typename Promise>
134 YACLIB_INLINE
void await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
135 auto& core = handle.promise();
136 core._executor = _executor;
138 if (!_event.TryAdd(*
this)) {
234 template <
typename Timeout>
235 bool TimedWait(
const Timeout&
timeout) {
245 static constexpr auto kEmpty = std::uintptr_t{0};
246 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 AwaitOn(IExecutor &e, FutureBase< V, E > &... fs) noexcept
YACLIB_INLINE auto Await(Task< V, E > &task) noexcept
TODO(mkornaukhov03) Add doxygen docs.
Contract< V, E > MakeContract()
Creates related future and promise.
Public only because Waiter is public.
void Call() noexcept final
Waiter is public for advanced users.
void Call() noexcept final