2 (C) Copyright 2007-8 Anthony Williams.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
8 [section:time Time Requirements]
10 As of Boost 1.50.0, the __boost_thread__ library uses Boost.Chrono library for all operations that require a
11 time out as defined in the standard c++11. These include (but are not limited to):
13 * `boost::this_thread::__sleep_for`
14 * `boost::this_thread::__sleep_until`
15 * `boost::__thread::__try_join_for`
16 * `boost::__thread::__try_join_until`
17 * `boost::__condition_variable::__wait_for`
18 * `boost::__condition_variable::__wait_until`
19 * `boost::__condition_variable_any::__cvany_wait_for`
20 * `boost::__condition_variable_any::__cvany_wait_until`
21 * `__TimedLockable::__try_lock_for`
22 * `__TimedLockable::__try_lock_until`
24 [section:deprecated Deprecated]
25 The time related functions introduced in Boost 1.35.0, using the [link date_time Boost.Date_Time] library are deprecated. These include (but are not limited to):
32 For the overloads that accept an absolute time parameter, an object of type [link thread.time.deprecated.system_time `boost::system_time`] is
33 required. Typically, this will be obtained by adding a duration to the current time, obtained with a call to [link
34 thread.time.deprecated.get_system_time `boost::get_system_time()`]. e.g.
36 boost::system_time const timeout=boost::get_system_time() + boost::posix_time::milliseconds(500);
39 extern boost::mutex m;
40 extern boost::condition_variable cond;
42 boost::unique_lock<boost::mutex> lk(m);
45 if(!cond.timed_wait(lk,timeout))
51 For the overloads that accept a ['TimeDuration] parameter, an object of any type that meets the [link
52 date_time.posix_time.time_duration Boost.Date_Time Time Duration requirements] can be used, e.g.
54 boost::this_thread::sleep(boost::posix_time::milliseconds(25));
57 if(m.timed_lock(boost::posix_time::nanoseconds(100)))
62 [section:system_time Typedef `system_time`]
64 #include <boost/thread/thread_time.hpp>
66 typedef boost::posix_time::ptime system_time;
68 See the documentation for [link date_time.posix_time.ptime_class `boost::posix_time::ptime`] in the Boost.Date_Time library.
72 [section:get_system_time Non-member function `get_system_time()`]
74 #include <boost/thread/thread_time.hpp>
76 system_time get_system_time();
80 [[Returns:] [The current time.]]
82 [[Throws:] [Nothing.]]