MCPcopy Create free account
hub / github.com/boostorg/asio / async_wait_twice

Function async_wait_twice

example/cpp14/deferred/deferred_5.cpp:17–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16template <typename CompletionToken>
17auto async_wait_twice(boost::asio::steady_timer& timer, CompletionToken&& token)
18{
19 return timer.async_wait(
20 deferred(
21 [&](boost::system::error_code ec)
22 {
23 std::cout << "first timer wait finished: " << ec.message() << "\n";
24 timer.expires_after(std::chrono::seconds(1));
25 return deferred.when(!ec)
26 .then(timer.async_wait(deferred))
27 .otherwise(deferred.values(ec));
28 }
29 )
30 )(
31 deferred(
32 [&](boost::system::error_code ec)
33 {
34 std::cout << "second timer wait finished: " << ec.message() << "\n";
35 return deferred.when(!ec)
36 .then(deferred.values(42))
37 .otherwise(deferred.values(0));
38 }
39 )
40 )(
41 std::forward<CompletionToken>(token)
42 );
43}
44
45int main()
46{

Callers 1

mainFunction · 0.70

Calls 4

whenMethod · 0.80
valuesMethod · 0.80
async_waitMethod · 0.45
expires_afterMethod · 0.45

Tested by

no test coverage detected