fiber
Loading...
Searching...
No Matches
fiber::Delay Class Reference

#include <Delay.hpp>

Public Member Functions

constexpr Delay (fiber::Duration delay)
 Constructs a delay that can be co_awaited and sends a signal to the scheduler for re-scheduling.
 
template<RoundingMethod rounding_type = RoundingMethod::Up, class Rep = unsigned int, CRatio Period = std::ratio<1>>
constexpr Delay (std::chrono::duration< Rep, Period > delay)
 Constructs a delay that can be co_awaited and sends a signal to the scheduler for re-scheduling with exposed rounding type
 
constexpr Delay (fiber::Duration delay, fiber::Duration relative_deadline)
 Constructs a delay that can be co_awaited and sends a signal to the scheduler for re-scheduleing.
 
constexpr bool await_ready () const noexcept
 return true if the awatiable is ready.
 
constexpr void await_resume () const noexcept
 A delay does not return a value to be read -> void
 
template<class ReturnType>
constexpr void await_suspend (std::coroutine_handle< fiber::CoroutinePromise< ReturnType > > handle) const noexcept
 

Constructor & Destructor Documentation

◆ Delay() [1/3]

fiber::Delay::Delay ( fiber::Duration delay)
inlineconstexpr

Constructs a delay that can be co_awaited and sends a signal to the scheduler for re-scheduling.

Re-schedules the task with the delay relative to now and infers the deadline from the previous execution.

The next ready time:

next_ready = Clock::now() + delay;

The next deadline:

next_deadline = Clock::now() + delay + (previous_deadline - previous_ready)
See also
CoSignal::ImplicitDelay
Parameters
delayThe delay by which the task will be re-scheduled

◆ Delay() [2/3]

template<RoundingMethod rounding_type = RoundingMethod::Up, class Rep = unsigned int, CRatio Period = std::ratio<1>>
fiber::Delay::Delay ( std::chrono::duration< Rep, Period > delay)
inlineconstexpr

Constructs a delay that can be co_awaited and sends a signal to the scheduler for re-scheduling with exposed rounding type

◆ Delay() [3/3]

fiber::Delay::Delay ( fiber::Duration delay,
fiber::Duration relative_deadline )
inlineconstexpr

Constructs a delay that can be co_awaited and sends a signal to the scheduler for re-scheduleing.

Re-schedules the task with the delay relative to now and the relative_deadline relative to the new ready time.

The next ready time:

next_ready = Clock::now() + delay;

The next deadline:

next_deadline = Clock::now() + delay + relative_deadline
Parameters
delayThe delay by which this task should be delayed
relative_deadlineThe added deadline after the delay
See also
CoSignal::ExplicitDelay

Member Function Documentation

◆ await_ready()

bool fiber::Delay::await_ready ( ) const
inlineconstexprnoexcept

return true if the awatiable is ready.

initially returns false on the first read, but true on the second. _ready is set true in await_suspend_signal()

◆ await_resume()

void fiber::Delay::await_resume ( ) const
inlineconstexprnoexcept

A delay does not return a value to be read -> void

◆ await_suspend()

template<class ReturnType>
void fiber::Delay::await_suspend ( std::coroutine_handle< fiber::CoroutinePromise< ReturnType > > handle) const
inlineconstexprnoexcept

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