]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/doc/time.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / thread / doc / time.qbk
1 [/
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).
6 ]
7
8 [section:time Time Requirements]
9
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):
12
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`
23
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):
26
27 * __sleep__
28 * __timed_join__
29 * __cond_timed_wait__
30 * __timed_lock_ref__
31
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.
35
36 boost::system_time const timeout=boost::get_system_time() + boost::posix_time::milliseconds(500);
37
38 extern bool done;
39 extern boost::mutex m;
40 extern boost::condition_variable cond;
41
42 boost::unique_lock<boost::mutex> lk(m);
43 while(!done)
44 {
45 if(!cond.timed_wait(lk,timeout))
46 {
47 throw "timed out";
48 }
49 }
50
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.
53
54 boost::this_thread::sleep(boost::posix_time::milliseconds(25));
55
56 boost::mutex m;
57 if(m.timed_lock(boost::posix_time::nanoseconds(100)))
58 {
59 // ...
60 }
61
62 [section:system_time Typedef `system_time`]
63
64 #include <boost/thread/thread_time.hpp>
65
66 typedef boost::posix_time::ptime system_time;
67
68 See the documentation for [link date_time.posix_time.ptime_class `boost::posix_time::ptime`] in the Boost.Date_Time library.
69
70 [endsect]
71
72 [section:get_system_time Non-member function `get_system_time()`]
73
74 #include <boost/thread/thread_time.hpp>
75
76 system_time get_system_time();
77
78 [variablelist
79
80 [[Returns:] [The current time.]]
81
82 [[Throws:] [Nothing.]]
83
84 ]
85
86 [endsect]
87 [endsect]
88
89
90 [endsect]