]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/example/cpp03/tutorial/timer3/timer.cpp
5 // Copyright (c) 2003-2017 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)
12 #include <boost/asio.hpp>
13 #include <boost/bind.hpp>
14 #include <boost/date_time/posix_time/posix_time.hpp>
16 void print(const boost::system::error_code
& /*e*/,
17 boost::asio::deadline_timer
* t
, int* count
)
21 std::cout
<< *count
<< std::endl
;
24 t
->expires_at(t
->expires_at() + boost::posix_time::seconds(1));
25 t
->async_wait(boost::bind(print
,
26 boost::asio::placeholders::error
, t
, count
));
32 boost::asio::io_context io
;
35 boost::asio::deadline_timer
t(io
, boost::posix_time::seconds(1));
36 t
.async_wait(boost::bind(print
,
37 boost::asio::placeholders::error
, &t
, &count
));
41 std::cout
<< "Final count is " << count
<< std::endl
;