morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::async::DelayAwaiter Class Reference

The awaiter delay() returns: suspends until a TimeoutScheduler entry fires, or until a stop withdraws it. More...

#include <coroutine.hpp>

Public Member Functions

 DelayAwaiter (detail::TimeoutScheduler &scheduler, std::chrono::milliseconds duration)
 ~DelayAwaiter ()
 Withdraws the wait if the frame is destroyed while suspended.
 DelayAwaiter (const DelayAwaiter &)=delete
DelayAwaiter & operator= (const DelayAwaiter &)=delete
 DelayAwaiter (DelayAwaiter &&)=delete
DelayAwaiter & operator= (DelayAwaiter &&)=delete
constexpr bool await_ready () const noexcept
template<typename Promise>
bool await_suspend (std::coroutine_handle< Promise > awaiting)
void await_resume ()

Detailed Description

The awaiter delay() returns: suspends until a TimeoutScheduler entry fires, or until a stop withdraws it.

Resumes on the executor the awaiting coroutine was running on (core-cpp's current executor), or on the scheduler's loop thread if there was none. With a stoppable token on the awaiting promise, a stop cancels the scheduler entry – its capture is released on the scheduler's loop – and resumes the coroutine with core::async::OperationCancelled on the same executor, or, with none, inline on the thread that requested the stop. Exactly one of the timer and the stop resumes it.

Definition at line 139 of file coroutine.hpp.

Constructor & Destructor Documentation

◆ DelayAwaiter()

morph::async::DelayAwaiter::DelayAwaiter ( detail::TimeoutScheduler & scheduler,
std::chrono::milliseconds duration )
inline
Parameters
schedulerThe scheduler whose entry times the wait; must outlive it.
durationHow long to wait at least.

Definition at line 196 of file coroutine.hpp.

◆ ~DelayAwaiter()

morph::async::DelayAwaiter::~DelayAwaiter ( )
inline

Withdraws the wait if the frame is destroyed while suspended.

Definition at line 202 of file coroutine.hpp.

Member Function Documentation

◆ await_ready()

bool morph::async::DelayAwaiter::await_ready ( ) const
inlinenodiscardconstexprnoexcept
Returns
Always false: every decision is await_suspend's.

Definition at line 217 of file coroutine.hpp.

◆ await_suspend()

template<typename Promise>
bool morph::async::DelayAwaiter::await_suspend ( std::coroutine_handle< Promise > awaiting)
inline
Template Parameters
PromiseThe awaiting coroutine's promise type.
Parameters
awaitingThe coroutine performing the co_await.
Returns
False to continue at once, when a stop was already requested; true once the timer is armed.

Definition at line 224 of file coroutine.hpp.

◆ await_resume()

void morph::async::DelayAwaiter::await_resume ( )
inline
Exceptions
core::async::OperationCancelledif a stop withdrew the wait.

Definition at line 259 of file coroutine.hpp.


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