MCPcopy Create free account
hub / github.com/boostorg/cobalt / wait_op

Class wait_op

example/delay_op.cpp:13–26  ·  view source on GitHub ↗

tag::timer_example[]

Source from the content-addressed store, hash-verified

11
12// tag::timer_example[]
13struct wait_op final : cobalt::op<system::error_code> // <1>
14{
15 asio::steady_timer & tim;
16 wait_op(asio::steady_timer & tim) : tim(tim) {}
17 void ready(cobalt::handler<system::error_code> h ) override // <2>
18 {
19 if (tim.expiry() < std::chrono::steady_clock::now())
20 h(system::error_code{});
21 }
22 void initiate(cobalt::completion_handler<system::error_code> complete) override // <3>
23 {
24 tim.async_wait(std::move(complete));
25 }
26};
27
28
29cobalt::main co_main(int argc, char * argv[])

Callers 1

co_mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected