]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/example/cpp14/deferred/deferred_4.cpp
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #include <boost/asio.hpp>
12 #include <boost/asio/experimental/deferred.hpp>
15 using boost::asio::experimental::deferred
;
17 template <typename CompletionToken
>
18 auto async_wait_twice(boost::asio::steady_timer
& timer
, CompletionToken
&& token
)
20 return timer
.async_wait(
22 [&](boost::system::error_code ec
)
24 std::cout
<< "first timer wait finished: " << ec
.message() << "\n";
25 timer
.expires_after(std::chrono::seconds(1));
26 return timer
.async_wait(deferred
);
31 [&](boost::system::error_code ec
)
33 std::cout
<< "second timer wait finished: " << ec
.message() << "\n";
34 return deferred
.values(42);
38 std::forward
<CompletionToken
>(token
)
44 boost::asio::io_context ctx
;
46 boost::asio::steady_timer
timer(ctx
);
47 timer
.expires_after(std::chrono::seconds(1));
53 std::cout
<< "result is " << result
<< "\n";