Skip to content

Commit

Permalink
adapter/darwin: atomic sync experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
Will committed Mar 8, 2024
1 parent 4d301f8 commit 235691d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions devel/include/detail/wtr/watcher/synchronized.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>& owner_flag) -> bool
Expand Down
11 changes: 9 additions & 2 deletions include/wtr/watcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>& owner_flag) -> bool
Expand Down

0 comments on commit 235691d

Please sign in to comment.