boost::capy::delay

Suspend the current coroutine for a duration.

Synopsis

Declared in <boost/capy/delay.hpp>

template<
    typename Rep,
    typename Period>
delay_awaitable
delay(std::chrono::duration<Rep, Period> dur) noexcept;

Description

Returns an IoAwaitable that completes at or after the specified duration, or earlier if the environment's stop token is activated.

Zero or negative durations complete synchronously without scheduling a timer.

Example

auto [ec] = co_await delay(std::chrono::milliseconds(100));

Return Value

A delay_awaitable whose await_resume returns io_result<>. On normal completion, ec is clear. On cancellation, ec == error::canceled.

Parameters

Name Description

dur

The duration to wait.

See Also

timeout, delay_awaitable

Created with MrDocs