[libcxx-commits] [libcxx] [libc++] refactor `cxx_atomic_wait` to make it reusable for atomic_ref (PR #81427)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 1 09:21:04 PST 2024
================
@@ -27,15 +31,45 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Atp, class _Poll>
-struct __libcpp_atomic_wait_poll_impl {
- _Atp* __a_;
+// The customisation points to enable the following functions:
+// - __atomic_wait
+// - __atomic_wait_unless
+// - __atomic_notify_one
+// - __atomic_notify_all
+// Note that std::atomic<T>::wait was back-ported to C++03
+// The below implementations look ugly to support C++03
+template <class _Tp, class = void>
+struct __atomic_waitable_customisations {
+ template <class _AtomicWaitable>
+ static void __atomic_load(_AtomicWaitable&&, memory_order) = delete;
+
+ template <class _AtomicWaitable>
+ static void __atomic_contention_address(_AtomicWaitable&&) = delete;
+};
+
+template <class _Tp>
+struct __atomic_waitable_customisations<_Tp, __enable_if_t<!__is_same(_Tp, __decay_t<_Tp>)> >
+ : __atomic_waitable_customisations<__decay_t<_Tp> > {};
----------------
ldionne wrote:
Personally, I feel like it is cleaner to expect a "clean" `_Tp` in the traits, and to make sure we pass that from the call site. This is the general expectation for traits-like classes, for example `iterator_traits` and `char_traits` do not attempt to sanitize the type passed to them.
https://github.com/llvm/llvm-project/pull/81427
More information about the libcxx-commits
mailing list