]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/include/boost/thread/poly_shared_lockable_adapter.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / thread / include / boost / thread / poly_shared_lockable_adapter.hpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://www.boost.org/libs/thread for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10
11 #ifndef BOOST_THREAD_POLY_SHARED_LOCKABLE_ADAPTER_HPP
12 #define BOOST_THREAD_POLY_SHARED_LOCKABLE_ADAPTER_HPP
13
14 #include <boost/thread/poly_lockable_adapter.hpp>
15 #include <boost/thread/poly_shared_lockable.hpp>
16
17 namespace boost
18 {
19
20 //[shared_lockable_adapter
21 template <typename Mutex, typename Base=poly_shared_lockable>
22 class poly_shared_lockable_adapter: public poly_timed_lockable_adapter<Mutex, Base>
23 {
24 public:
25 typedef Mutex mutex_type;
26
27 void lock_shared()
28 {
29 this->mtx().lock_shared();
30 }
31 bool try_lock_shared()
32 {
33 return this->mtx().try_lock_shared();
34 }
35 void unlock_shared()
36 {
37 this->mtx().unlock_shared();
38 }
39
40 bool try_lock_shared_until(chrono::system_clock::time_point const & abs_time)
41 {
42 return this->mtx().try_lock_shared_until(abs_time);
43 }
44 bool try_lock_shared_until(chrono::steady_clock::time_point const & abs_time)
45 {
46 return this->mtx().try_lock_shared_until(abs_time);
47 }
48 bool try_lock_shared_for(chrono::nanoseconds const & rel_time)
49 {
50 return this->mtx().try_lock_shared_for(rel_time);
51 }
52
53 };
54
55 //]
56
57 //[upgrade_lockable_adapter
58 template <typename Mutex, typename Base=poly_shared_lockable>
59 class upgrade_lockable_adapter: public shared_lockable_adapter<Mutex, Base>
60 {
61 public:
62 typedef Mutex mutex_type;
63
64 void lock_upgrade()
65 {
66 this->mtx().lock_upgrade();
67 }
68
69 bool try_lock_upgrade()
70 {
71 return this->mtx().try_lock_upgrade();
72 }
73
74 void unlock_upgrade()
75 {
76 this->mtx().unlock_upgrade();
77 }
78
79 bool try_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)
80 {
81 return this->mtx().try_lock_upgrade_until(abs_time);
82 }
83 bool try_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)
84 {
85 return this->mtx().try_lock_upgrade_until(abs_time);
86 }
87 bool try_lock_upgrade_for(chrono::nanoseconds const & rel_time)
88 {
89 return this->mtx().try_lock_upgrade_for(rel_time);
90 }
91
92 bool try_unlock_shared_and_lock()
93 {
94 return this->mtx().try_unlock_shared_and_lock();
95 }
96
97 bool try_unlock_shared_and_lock_until(chrono::system_clock::time_point const & abs_time)
98 {
99 return this->mtx().try_unlock_shared_and_lock_until(abs_time);
100 }
101 bool try_unlock_shared_and_lock_until(chrono::steady_clock::time_point const & abs_time)
102 {
103 return this->mtx().try_unlock_shared_and_lock_until(abs_time);
104 }
105 template <typename Rep, typename Period>
106 bool try_unlock_shared_and_lock_for(chrono::nanoseconds const & rel_time)
107 {
108 return this->mtx().try_unlock_shared_and_lock_for(rel_time);
109 }
110
111 void unlock_and_lock_shared()
112 {
113 this->mtx().unlock_and_lock_shared();
114 }
115
116 bool try_unlock_shared_and_lock_upgrade()
117 {
118 return this->mtx().try_unlock_shared_and_lock_upgrade();
119 }
120
121 bool try_unlock_shared_and_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)
122 {
123 return this->mtx().try_unlock_shared_and_lock_upgrade_until(abs_time);
124 }
125 bool try_unlock_shared_and_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)
126 {
127 return this->mtx().try_unlock_shared_and_lock_upgrade_until(abs_time);
128 }
129 bool try_unlock_shared_and_lock_upgrade_for(chrono::nanoseconds const & rel_time)
130 {
131 return this->mtx().try_unlock_shared_and_lock_upgrade_for(rel_time);
132 }
133
134 void unlock_and_lock_upgrade()
135 {
136 this->mtx().unlock_and_lock_upgrade();
137 }
138
139 void unlock_upgrade_and_lock()
140 {
141 this->mtx().unlock_upgrade_and_lock();
142 }
143
144 bool try_unlock_upgrade_and_lock()
145 {
146 return this->mtx().try_unlock_upgrade_and_lock();
147 }
148 bool try_unlock_upgrade_and_lock_until(chrono::system_clock::time_point const & abs_time)
149 {
150 return this->mtx().try_unlock_upgrade_and_lock_until(abs_time);
151 }
152 bool try_unlock_upgrade_and_lock_until(chrono::steady_clock::time_point const & abs_time)
153 {
154 return this->mtx().try_unlock_upgrade_and_lock_until(abs_time);
155 }
156 bool try_unlock_upgrade_and_lock_for(chrono::nanoseconds const & rel_time)
157 {
158 return this->mtx().try_unlock_upgrade_and_lock_for(rel_time);
159 }
160
161 void unlock_upgrade_and_lock_shared()
162 {
163 this->mtx().unlock_upgrade_and_lock_shared();
164 }
165
166 };
167 //]
168
169 }
170 #endif