]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/thread/poly_shared_lockable_adapter.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / 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 //[poly_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 //[poly_upgrade_lockable_adapter
58 template <typename Mutex, typename Base=poly_shared_lockable>
59 class poly_upgrade_lockable_adapter: public poly_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 bool try_unlock_shared_and_lock_for(chrono::nanoseconds const & rel_time)
106 {
107 return this->mtx().try_unlock_shared_and_lock_for(rel_time);
108 }
109
110 void unlock_and_lock_shared()
111 {
112 this->mtx().unlock_and_lock_shared();
113 }
114
115 bool try_unlock_shared_and_lock_upgrade()
116 {
117 return this->mtx().try_unlock_shared_and_lock_upgrade();
118 }
119
120 bool try_unlock_shared_and_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)
121 {
122 return this->mtx().try_unlock_shared_and_lock_upgrade_until(abs_time);
123 }
124 bool try_unlock_shared_and_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)
125 {
126 return this->mtx().try_unlock_shared_and_lock_upgrade_until(abs_time);
127 }
128 bool try_unlock_shared_and_lock_upgrade_for(chrono::nanoseconds const & rel_time)
129 {
130 return this->mtx().try_unlock_shared_and_lock_upgrade_for(rel_time);
131 }
132
133 void unlock_and_lock_upgrade()
134 {
135 this->mtx().unlock_and_lock_upgrade();
136 }
137
138 void unlock_upgrade_and_lock()
139 {
140 this->mtx().unlock_upgrade_and_lock();
141 }
142
143 bool try_unlock_upgrade_and_lock()
144 {
145 return this->mtx().try_unlock_upgrade_and_lock();
146 }
147 bool try_unlock_upgrade_and_lock_until(chrono::system_clock::time_point const & abs_time)
148 {
149 return this->mtx().try_unlock_upgrade_and_lock_until(abs_time);
150 }
151 bool try_unlock_upgrade_and_lock_until(chrono::steady_clock::time_point const & abs_time)
152 {
153 return this->mtx().try_unlock_upgrade_and_lock_until(abs_time);
154 }
155 bool try_unlock_upgrade_and_lock_for(chrono::nanoseconds const & rel_time)
156 {
157 return this->mtx().try_unlock_upgrade_and_lock_for(rel_time);
158 }
159
160 void unlock_upgrade_and_lock_shared()
161 {
162 this->mtx().unlock_upgrade_and_lock_shared();
163 }
164
165 };
166 //]
167
168 }
169 #endif