2 / Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 [section:timers Timers]
10 Long running I/O operations will often have a deadline by which they must have
11 completed. These deadlines may be expressed as absolute times, but are often
12 calculated relative to the current time.
14 As a simple example, to perform a synchronous wait operation on a timer using a
15 relative time one may write:
20 t.expires_from_now(boost::posix_time::seconds(5));
23 More commonly, a program will perform an asynchronous wait operation on a
26 void handler(boost::system::error_code ec) { ... }
31 t.expires_from_now(boost::posix_time::milliseconds(400));
32 t.async_wait(handler);
36 The deadline associated with a timer may also be obtained as a relative time:
38 boost::posix_time::time_duration time_until_expiry
39 = t.expires_from_now();
41 or as an absolute time to allow composition of timers:
44 t2.expires_at(t.expires_at() + boost::posix_time::seconds(30));
48 [link boost_asio.reference.basic_deadline_timer basic_deadline_timer],
49 [link boost_asio.reference.deadline_timer deadline_timer],
50 [link boost_asio.reference.deadline_timer_service deadline_timer_service],
51 [link boost_asio.tutorial.tuttimer1 timer tutorials].