[libcxx-commits] [libcxx] [libc++] Explicitly use the dual-cv implementation from shared_timed_mutex (PR #148044)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 11 01:00:08 PDT 2025
================
@@ -162,6 +162,26 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base {
static const unsigned __write_entered_ = 1U << (sizeof(unsigned) * __CHAR_BIT__ - 1);
static const unsigned __n_readers_ = ~__write_entered_;
+ _LIBCPP_HIDE_FROM_ABI __dual_cv_shared_mutex() : __state_(0) {}
+ _LIBCPP_HIDE_FROM_ABI ~__dual_cv_shared_mutex() = default;
+
+ __dual_cv_shared_mutex(const __dual_cv_shared_mutex&) = delete;
+ __dual_cv_shared_mutex& operator=(const __dual_cv_shared_mutex&) = delete;
+
+ // Exclusive ownership
+ _LIBCPP_HIDE_FROM_ABI void lock();
+ _LIBCPP_HIDE_FROM_ABI bool try_lock();
+ _LIBCPP_HIDE_FROM_ABI void unlock();
+
+ // Shared ownership
+ _LIBCPP_HIDE_FROM_ABI void lock_shared();
+ _LIBCPP_HIDE_FROM_ABI bool try_lock_shared();
+ _LIBCPP_HIDE_FROM_ABI void unlock_shared();
----------------
philnik777 wrote:
Adding `_LIBCPP_HIDE_FROM_ABI` to something that is implemented in the dylib like this feels very wrong. I also don't understand why we need to intoduce `__dual_cv_shared_mutex`. This seems like more effort than it's worth. We can just introduce a new `__native_shared_mutex` and keep the old `__shared_mutex_base` as the `__dual_cv` version. The naming might not be perfect, but we have to keep it around anyways, so I don't see how this improves anything.
https://github.com/llvm/llvm-project/pull/148044
More information about the libcxx-commits
mailing list