boost::corosio::timer::wait
Wait for the timer to expire.
Synopsis
Declared in <boost/corosio/timer.hpp>
auto
wait();
Description
The operation supports cancellation via std::stop_token through the affine awaitable protocol. If the associated stop token is triggered, the operation completes immediately with an error that compares equal to capy::cond::canceled.
Example
timer t(ctx);
t.expires_after(std::chrono::seconds(5));
auto [ec] = co_await t.wait();
if (ec == capy::cond::canceled)
{
// Cancelled via stop_token or cancel()
co_return;
}
if (ec)
{
// Handle other errors
co_return;
}
// Timer expired
Preconditions
The timer must have an expiry time set via expires_at() or expires_after().
Return Value
An awaitable that completes with io_result<>. Returns success (default error_code) when the timer expires, or an error code on failure. Compare against error conditions (e.g., ec == capy::cond::canceled) rather than error codes.
Created with MrDocs