@@ -153,8 +153,7 @@ _LIBCPP_PUSH_MACROS
153
153
154
154
_LIBCPP_BEGIN_NAMESPACE_STD
155
155
156
- struct _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_SHARED_MUTEX
157
- _LIBCPP_THREAD_SAFETY_ANNOTATION (capability(" shared_mutex" )) __shared_mutex_base {
156
+ struct _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_SHARED_MUTEX __shared_mutex_base {
158
157
mutex __mut_;
159
158
condition_variable __gate1_;
160
159
condition_variable __gate2_;
@@ -170,21 +169,22 @@ _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("shared_mutex")) __shared_mutex_base
170
169
__shared_mutex_base& operator =(const __shared_mutex_base&) = delete ;
171
170
172
171
// Exclusive ownership
173
- void lock () _LIBCPP_THREAD_SAFETY_ANNOTATION ( acquire_capability ()) ; // blocking
174
- bool try_lock () _LIBCPP_THREAD_SAFETY_ANNOTATION ( try_acquire_capability ( true )) ;
175
- void unlock () _LIBCPP_THREAD_SAFETY_ANNOTATION ( release_capability ()) ;
172
+ void lock (); // blocking
173
+ bool try_lock ();
174
+ void unlock ();
176
175
177
176
// Shared ownership
178
- void lock_shared () _LIBCPP_THREAD_SAFETY_ANNOTATION ( acquire_shared_capability ()) ; // blocking
179
- bool try_lock_shared () _LIBCPP_THREAD_SAFETY_ANNOTATION ( try_acquire_shared_capability ( true )) ;
180
- void unlock_shared () _LIBCPP_THREAD_SAFETY_ANNOTATION ( release_shared_capability ()) ;
177
+ void lock_shared (); // blocking
178
+ bool try_lock_shared ();
179
+ void unlock_shared ();
181
180
182
181
// typedef implementation-defined native_handle_type; // See 30.2.3
183
182
// native_handle_type native_handle(); // See 30.2.3
184
183
};
185
184
186
185
# if _LIBCPP_STD_VER >= 17
187
- class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_mutex {
186
+ class _LIBCPP_EXPORTED_FROM_ABI
187
+ _LIBCPP_AVAILABILITY_SHARED_MUTEX _LIBCPP_THREAD_SAFETY_ANNOTATION (__capability__(" shared_mutex" )) shared_mutex {
188
188
__shared_mutex_base __base_;
189
189
190
190
public:
@@ -195,21 +195,35 @@ public:
195
195
shared_mutex& operator =(const shared_mutex&) = delete ;
196
196
197
197
// Exclusive ownership
198
- _LIBCPP_HIDE_FROM_ABI void lock () { return __base_.lock (); }
199
- _LIBCPP_HIDE_FROM_ABI bool try_lock () { return __base_.try_lock (); }
200
- _LIBCPP_HIDE_FROM_ABI void unlock () { return __base_.unlock (); }
198
+ _LIBCPP_HIDE_FROM_ABI void lock () _LIBCPP_THREAD_SAFETY_ANNOTATION (__acquire_capability__ ()) {
199
+ return __base_.lock ();
200
+ }
201
+ _LIBCPP_HIDE_FROM_ABI bool try_lock () _LIBCPP_THREAD_SAFETY_ANNOTATION (__try_acquire_capability__ (true )) {
202
+ return __base_.try_lock ();
203
+ }
204
+ _LIBCPP_HIDE_FROM_ABI void unlock () _LIBCPP_THREAD_SAFETY_ANNOTATION (__release_capability__ ()) {
205
+ return __base_.unlock ();
206
+ }
201
207
202
208
// Shared ownership
203
- _LIBCPP_HIDE_FROM_ABI void lock_shared () { return __base_.lock_shared (); }
204
- _LIBCPP_HIDE_FROM_ABI bool try_lock_shared () { return __base_.try_lock_shared (); }
205
- _LIBCPP_HIDE_FROM_ABI void unlock_shared () { return __base_.unlock_shared (); }
209
+ _LIBCPP_HIDE_FROM_ABI void lock_shared () _LIBCPP_THREAD_SAFETY_ANNOTATION (__acquire_shared_capability__ ()) {
210
+ return __base_.lock_shared ();
211
+ }
212
+ _LIBCPP_HIDE_FROM_ABI bool try_lock_shared ()
213
+ _LIBCPP_THREAD_SAFETY_ANNOTATION (__try_acquire_shared_capability__ (true )) {
214
+ return __base_.try_lock_shared ();
215
+ }
216
+ _LIBCPP_HIDE_FROM_ABI void unlock_shared () _LIBCPP_THREAD_SAFETY_ANNOTATION (__release_shared_capability__ ()) {
217
+ return __base_.unlock_shared ();
218
+ }
206
219
207
220
// typedef __shared_mutex_base::native_handle_type native_handle_type;
208
221
// _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); }
209
222
};
210
223
# endif
211
224
212
- class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_timed_mutex {
225
+ class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_SHARED_MUTEX _LIBCPP_THREAD_SAFETY_ANNOTATION (
226
+ __capability__ (" shared_timed_mutex" )) shared_timed_mutex {
213
227
__shared_mutex_base __base_;
214
228
215
229
public:
@@ -220,28 +234,32 @@ public:
220
234
shared_timed_mutex& operator =(const shared_timed_mutex&) = delete ;
221
235
222
236
// Exclusive ownership
223
- void lock ();
224
- bool try_lock ();
237
+ void lock () _LIBCPP_THREAD_SAFETY_ANNOTATION ( __acquire_capability__ ()) ;
238
+ bool try_lock () _LIBCPP_THREAD_SAFETY_ANNOTATION ( __try_acquire_capability__ ( true )) ;
225
239
template <class _Rep , class _Period >
226
- _LIBCPP_HIDE_FROM_ABI bool try_lock_for (const chrono::duration<_Rep, _Period>& __rel_time) {
240
+ _LIBCPP_HIDE_FROM_ABI bool try_lock_for (const chrono::duration<_Rep, _Period>& __rel_time)
241
+ _LIBCPP_THREAD_SAFETY_ANNOTATION (__try_acquire_capability__ (true )) {
227
242
return try_lock_until (chrono::steady_clock::now () + __rel_time);
228
243
}
229
244
template <class _Clock , class _Duration >
230
245
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool
231
- try_lock_until (const chrono::time_point<_Clock, _Duration>& __abs_time);
232
- void unlock ();
246
+ try_lock_until (const chrono::time_point<_Clock, _Duration>& __abs_time)
247
+ _LIBCPP_THREAD_SAFETY_ANNOTATION (__try_acquire_capability__ (true ));
248
+ void unlock () _LIBCPP_THREAD_SAFETY_ANNOTATION (__release_capability__ ());
233
249
234
250
// Shared ownership
235
- void lock_shared ();
236
- bool try_lock_shared ();
251
+ void lock_shared () _LIBCPP_THREAD_SAFETY_ANNOTATION ( __acquire_shared_capability__ ()) ;
252
+ bool try_lock_shared () _LIBCPP_THREAD_SAFETY_ANNOTATION ( __try_acquire_shared_capability__ ( true )) ;
237
253
template <class _Rep , class _Period >
238
- _LIBCPP_HIDE_FROM_ABI bool try_lock_shared_for (const chrono::duration<_Rep, _Period>& __rel_time) {
254
+ _LIBCPP_HIDE_FROM_ABI bool try_lock_shared_for (const chrono::duration<_Rep, _Period>& __rel_time)
255
+ _LIBCPP_THREAD_SAFETY_ANNOTATION (__try_acquire_shared_capability__ (true )) {
239
256
return try_lock_shared_until (chrono::steady_clock::now () + __rel_time);
240
257
}
241
258
template <class _Clock , class _Duration >
242
259
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool
243
- try_lock_shared_until (const chrono::time_point<_Clock, _Duration>& __abs_time);
244
- void unlock_shared ();
260
+ try_lock_shared_until (const chrono::time_point<_Clock, _Duration>& __abs_time)
261
+ _LIBCPP_THREAD_SAFETY_ANNOTATION (__try_acquire_shared_capability__ (true ));
262
+ void unlock_shared () _LIBCPP_THREAD_SAFETY_ANNOTATION (__release_shared_capability__ ());
245
263
};
246
264
247
265
template <class _Clock , class _Duration >
0 commit comments