[libcxx-commits] [libcxx] [libc++] Replace mutex+condvar with atomics in __call_once (PR #192433)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 23 07:23:30 PDT 2026


================
@@ -25,8 +27,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 // keep in sync with:  7741191.
 
 #if _LIBCPP_HAS_THREADS
-static constinit __libcpp_mutex_t mut  = _LIBCPP_MUTEX_INITIALIZER;
-static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
+_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT;
----------------
huixie90 wrote:

The difference comes from the fact in std::atomic, we poll for 4us before calling into the system api. I tend to agree with Nicolas, the current PR is harder to read and the functions are really not designed to be used outside atomic_sync (which does some ABI flag dispatch). We probably should expose some internal APIs from std::atomic to have easy way to wait without 4us polling (or we should just get rid of the 4us polling from atomic::wait)

https://github.com/llvm/llvm-project/pull/192433


More information about the libcxx-commits mailing list