]>
Commit | Line | Data |
---|---|---|
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_NULL_MUTEX_HPP | |
12 | #define BOOST_THREAD_NULL_MUTEX_HPP | |
13 | ||
14 | #include <boost/thread/detail/config.hpp> | |
15 | #include <boost/thread/detail/delete.hpp> | |
16 | #include <boost/chrono/chrono.hpp> | |
17 | ||
18 | /// \file | |
19 | /// Describes null_mutex class | |
20 | ||
21 | namespace boost | |
22 | { | |
23 | ||
24 | /// Implements a mutex that simulates a mutex without doing any operation and | |
25 | /// simulates a successful operation. | |
26 | class null_mutex | |
27 | { | |
28 | public: | |
29 | ||
30 | BOOST_THREAD_NO_COPYABLE( null_mutex) /*< no copyable >*/ | |
31 | ||
32 | null_mutex() {} | |
33 | ||
34 | /// Simulates a mutex lock() operation. Empty function. | |
35 | void lock() | |
36 | { | |
37 | } | |
38 | ||
39 | /// Simulates a mutex try_lock() operation. | |
40 | /// Equivalent to "return true;" | |
41 | bool try_lock() | |
42 | { | |
43 | return true; | |
44 | } | |
45 | ||
46 | /// Simulates a mutex unlock() operation. | |
47 | /// Empty function. | |
48 | void unlock() | |
49 | { | |
50 | } | |
51 | ||
52 | #ifdef BOOST_THREAD_USES_CHRONO | |
53 | /// Simulates a mutex try_lock_until() operation. | |
54 | /// Equivalent to "return true;" | |
55 | template <typename Clock, typename Duration> | |
56 | bool try_lock_until(chrono::time_point<Clock, Duration> const &) | |
57 | { | |
58 | return true; | |
59 | } | |
60 | ||
61 | /// Simulates a mutex try_lock_for() operation. | |
62 | /// Equivalent to "return true;" | |
63 | template <typename Rep, typename Period> | |
64 | bool try_lock_for(chrono::duration<Rep, Period> const &) | |
65 | { | |
66 | return true; | |
67 | } | |
68 | #endif | |
69 | ||
70 | /// Simulates a mutex lock_shared() operation. | |
71 | /// Empty function. | |
72 | void lock_shared() | |
73 | { | |
74 | } | |
75 | ||
76 | /// Simulates a mutex try_lock_shared() operation. | |
77 | /// Equivalent to "return true;" | |
78 | bool try_lock_shared() | |
79 | { | |
80 | return true; | |
81 | } | |
82 | ||
83 | /// Simulates a mutex unlock_shared() operation. | |
84 | /// Empty function. | |
85 | void unlock_shared() | |
86 | { | |
87 | } | |
88 | ||
89 | /// Simulates a mutex try_lock_shared_until() operation. | |
90 | /// Equivalent to "return true;" | |
91 | template <typename Clock, typename Duration> | |
92 | bool try_lock_shared_until(chrono::time_point<Clock, Duration> const &) | |
93 | { | |
94 | return true; | |
95 | } | |
96 | /// Simulates a mutex try_lock_shared_for() operation. | |
97 | /// Equivalent to "return true;" | |
98 | template <typename Rep, typename Period> | |
99 | bool try_lock_shared_for(chrono::duration<Rep, Period> const &) | |
100 | { | |
101 | return true; | |
102 | } | |
103 | ||
104 | /// Simulates a mutex lock_upgrade() operation. | |
105 | /// Empty function. | |
106 | void lock_upgrade() | |
107 | { | |
108 | } | |
109 | ||
110 | /// Simulates a mutex try_lock_upgrade() operation. | |
111 | /// Equivalent to "return true;" | |
112 | bool try_lock_upgrade() | |
113 | { | |
114 | return true; | |
115 | } | |
116 | ||
117 | /// Simulates a mutex unlock_upgrade() operation. | |
118 | /// Empty function. | |
119 | void unlock_upgrade() | |
120 | { | |
121 | } | |
122 | ||
123 | /// Simulates a mutex try_lock_upgrade_until() operation. | |
124 | /// Equivalent to "return true;" | |
125 | template <typename Clock, typename Duration> | |
126 | bool try_lock_upgrade_until(chrono::time_point<Clock, Duration> const &) | |
127 | { | |
128 | return true; | |
129 | } | |
130 | ||
131 | /// Simulates a mutex try_lock_upgrade_for() operation. | |
132 | /// Equivalent to "return true;" | |
133 | template <typename Rep, typename Period> | |
134 | bool try_lock_upgrade_for(chrono::duration<Rep, Period> const &) | |
135 | { | |
136 | return true; | |
137 | } | |
138 | ||
139 | /// Simulates a mutex try_unlock_shared_and_lock() operation. | |
140 | /// Equivalent to "return true;" | |
141 | bool try_unlock_shared_and_lock() | |
142 | { | |
143 | return true; | |
144 | } | |
145 | ||
146 | #ifdef BOOST_THREAD_USES_CHRONO | |
147 | /// Simulates a mutex try_unlock_shared_and_lock_until() operation. | |
148 | /// Equivalent to "return true;" | |
149 | template <typename Clock, typename Duration> | |
150 | bool try_unlock_shared_and_lock_until(chrono::time_point<Clock, Duration> const &) | |
151 | { | |
152 | return true; | |
153 | } | |
154 | ||
155 | /// Simulates a mutex try_unlock_shared_and_lock_for() operation. | |
156 | /// Equivalent to "return true;" | |
157 | template <typename Rep, typename Period> | |
158 | bool try_unlock_shared_and_lock_for(chrono::duration<Rep, Period> const &) | |
159 | { | |
160 | return true; | |
161 | } | |
162 | #endif | |
163 | ||
164 | /// Simulates unlock_and_lock_shared(). | |
165 | /// Empty function. | |
166 | void unlock_and_lock_shared() | |
167 | { | |
168 | } | |
169 | ||
170 | /// Simulates a mutex try_unlock_shared_and_lock_upgrade() operation. | |
171 | /// Equivalent to "return true;" | |
172 | bool try_unlock_shared_and_lock_upgrade() | |
173 | { | |
174 | return true; | |
175 | } | |
176 | ||
177 | #ifdef BOOST_THREAD_USES_CHRONO | |
178 | /// Simulates a mutex try_unlock_shared_and_lock_upgrade_until() operation. | |
179 | /// Equivalent to "return true;" | |
180 | template <typename Clock, typename Duration> | |
181 | bool try_unlock_shared_and_lock_upgrade_until(chrono::time_point<Clock, Duration> const &) | |
182 | { | |
183 | return true; | |
184 | } | |
185 | ||
186 | /// Simulates a mutex try_unlock_shared_and_lock_upgrade_for() operation. | |
187 | /// Equivalent to "return true;" | |
188 | template <typename Rep, typename Period> | |
189 | bool try_unlock_shared_and_lock_upgrade_for(chrono::duration<Rep, Period> const &) | |
190 | { | |
191 | return true; | |
192 | } | |
193 | #endif | |
194 | ||
195 | /// Simulates unlock_and_lock_upgrade(). | |
196 | /// Empty function. | |
197 | void unlock_and_lock_upgrade() | |
198 | { | |
199 | } | |
200 | ||
201 | /// Simulates unlock_upgrade_and_lock(). | |
202 | /// Empty function. | |
203 | void unlock_upgrade_and_lock() | |
204 | { | |
205 | } | |
206 | ||
207 | /// Simulates a mutex try_unlock_upgrade_and_lock() operation. | |
208 | /// Equivalent to "return true;" | |
209 | bool try_unlock_upgrade_and_lock() | |
210 | { | |
211 | return true; | |
212 | } | |
213 | ||
214 | #ifdef BOOST_THREAD_USES_CHRONO | |
215 | /// Simulates a mutex try_unlock_upgrade_and_lock_until() operation. | |
216 | /// Equivalent to "return true;" | |
217 | template <typename Clock, typename Duration> | |
218 | bool try_unlock_upgrade_and_lock_until(chrono::time_point<Clock, Duration> const &) | |
219 | { | |
220 | return true; | |
221 | } | |
222 | ||
223 | /// Simulates a mutex try_unlock_upgrade_and_lock_for() operation. | |
224 | /// Equivalent to "return true;" | |
225 | template <typename Rep, typename Period> | |
226 | bool try_unlock_upgrade_and_lock_for(chrono::duration<Rep, Period> const &) | |
227 | { | |
228 | return true; | |
229 | } | |
230 | #endif | |
231 | ||
232 | /// Simulates unlock_upgrade_and_lock_shared(). | |
233 | /// Empty function. | |
234 | void unlock_upgrade_and_lock_shared() | |
235 | { | |
236 | } | |
237 | ||
238 | }; | |
239 | ||
240 | } //namespace boost { | |
241 | ||
242 | ||
243 | #endif |