From 235691d110eb3f5934c9d1ab7081d8d04a06adaa Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 7 Mar 2024 22:51:20 -0500 Subject: [PATCH] adapter/darwin: atomic sync experiments --- devel/include/detail/wtr/watcher/synchronized.hpp | 11 +++++++++-- include/wtr/watcher.hpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/devel/include/detail/wtr/watcher/synchronized.hpp b/devel/include/detail/wtr/watcher/synchronized.hpp index 7878f20e..cfda9157 100644 --- a/devel/include/detail/wtr/watcher/synchronized.hpp +++ b/devel/include/detail/wtr/watcher/synchronized.hpp @@ -34,11 +34,18 @@ class Synchronized { bool exchange_when_current_is, bool want_value) -> bool { +#ifdef WTR_ALLOW_NON_SEQUENTIAL_CONSISTENCY + constexpr auto relord = std::memory_order_release; + constexpr auto acqord = std::memory_order_acquire; +#else + constexpr auto relord = std::memory_order_seq_cst; + constexpr auto acqord = std::memory_order_seq_cst; +#endif return current_value.compare_exchange_strong( exchange_when_current_is, want_value, - std::memory_order_release, - std::memory_order_acquire); + acqord, + relord); } inline static auto try_take(std::atomic& owner_flag) -> bool diff --git a/include/wtr/watcher.hpp b/include/wtr/watcher.hpp index 1b045490..591aa387 100644 --- a/include/wtr/watcher.hpp +++ b/include/wtr/watcher.hpp @@ -502,11 +502,18 @@ class Synchronized { bool exchange_when_current_is, bool want_value) -> bool { +#ifdef WTR_ALLOW_NON_SEQUENTIAL_CONSISTENCY + constexpr auto relord = std::memory_order_release; + constexpr auto acqord = std::memory_order_acquire; +#else + constexpr auto relord = std::memory_order_seq_cst; + constexpr auto acqord = std::memory_order_seq_cst; +#endif return current_value.compare_exchange_strong( exchange_when_current_is, want_value, - std::memory_order_release, - std::memory_order_acquire); + acqord, + relord); } inline static auto try_take(std::atomic& owner_flag) -> bool