[libcxx-commits] [libcxx] [libc++] add shared_recursive_mutex api (PR #82466)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 27 00:21:45 PST 2024
================
@@ -0,0 +1,122 @@
+#include <cassert>
+#include <shared_recursive_mutex>
+
+constexpr uint32_t SHARED_USER_MAX_CNT = UINT32_MAX;
+constexpr pthread_t THREAD_ID_NOEXIST = 0;
+
+using namespace std;
+
+#ifndef likely
+# define likely(condition) __builtin_expect(!!(condition), 1)
+#endif
+#ifndef unlikely
+# define unlikely(condition) __builtin_expect(!!(condition), 0)
+#endif
+
+void shared_recursive_mutex::lock() {
+ pthread_t self = pthread_self();
----------------
frederick-vs-ja wrote:
If it's intended to support non-pthread platforms ...
```suggestion
__thread_id self = this_thead::get_id();
```
(ditto for other `self` definitions)
https://github.com/llvm/llvm-project/pull/82466
More information about the libcxx-commits
mailing list