[libcxx] r346567 - [libcxx] Provide thread annotations for shared_mutex

Petr Hosek phosek at chromium.org
Fri Nov 9 15:32:26 PST 2018


Author: phosek
Date: Fri Nov  9 15:32:25 2018
New Revision: 346567

URL: http://llvm.org/viewvc/llvm-project?rev=346567&view=rev
Log:
[libcxx] Provide thread annotations for shared_mutex

shared_mutex was introduced in C++17 but its implementation currently
doesn't use Clang's thread annotations like regular mutex. This change
adds those.

Differential Revision: https://reviews.llvm.org/D54290

Modified:
    libcxx/trunk/include/shared_mutex

Modified: libcxx/trunk/include/shared_mutex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/shared_mutex?rev=346567&r1=346566&r2=346567&view=diff
==============================================================================
--- libcxx/trunk/include/shared_mutex (original)
+++ libcxx/trunk/include/shared_mutex Fri Nov  9 15:32:25 2018
@@ -144,7 +144,8 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-struct _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX __shared_mutex_base
+struct _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("shared_mutex"))
+__shared_mutex_base
 {
     mutex               __mut_;
     condition_variable  __gate1_;
@@ -161,14 +162,14 @@ struct _LIBCPP_TYPE_VIS _LIBCPP_AVAILABI
     __shared_mutex_base& operator=(const __shared_mutex_base&) = delete;
 
     // Exclusive ownership
-    void lock(); // blocking
-    bool try_lock();
-    void unlock();
+    void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability()); // blocking
+    bool try_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
+    void unlock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
 
     // Shared ownership
-    void lock_shared(); // blocking
-    bool try_lock_shared();
-    void unlock_shared();
+    void lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_shared_capability()); // blocking
+    bool try_lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_shared_capability(true));
+    void unlock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_shared_capability());
 
 //     typedef implementation-defined native_handle_type; // See 30.2.3
 //     native_handle_type native_handle(); // See 30.2.3




More information about the libcxx-commits mailing list