[libcxx-commits] [libcxx] [libc++] Speed up classic locale (PR #72112)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Nov 15 10:34:18 PST 2023
================
@@ -538,16 +543,31 @@ locale::__imp::use_facet(long id) const
// locale
+std::atomic<locale::__imp*> locale::__imp::classic_;
+
const locale&
locale::__imp::make_classic()
{
// only one thread can get in here and it only gets in once
alignas(locale) static std::byte buf[sizeof(locale)];
locale* c = reinterpret_cast<locale*>(&buf);
c->__locale_ = &make<__imp>(1u);
+ classic_.store(c->__locale_, std::memory_order_relaxed);
----------------
mordante wrote:
I only see `memory_order_relaxed` in the usage. How are the atomic reads and writes synchronized?
https://github.com/llvm/llvm-project/pull/72112
More information about the libcxx-commits
mailing list