From b087f9fb5313057d40dbaab8c5c88c026bc01200 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Mon, 11 Dec 2023 18:54:10 +0100 Subject: [PATCH] strengthened memory order for metadata manipulation --- .../boost/unordered/detail/foa/concurrent_table.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/boost/unordered/detail/foa/concurrent_table.hpp b/include/boost/unordered/detail/foa/concurrent_table.hpp index 47994fd6..6186d9d7 100644 --- a/include/boost/unordered/detail/foa/concurrent_table.hpp +++ b/include/boost/unordered/detail/foa/concurrent_table.hpp @@ -205,6 +205,17 @@ private: template struct atomic_integral { +#if defined(BOOST_UNORDERED_LATCH_FREE) + operator Integral()const{return n.load();} + void operator=(Integral m){n.store(m);} + void operator|=(Integral m){n.fetch_or(m);} + void operator&=(Integral m){n.fetch_and(m);} + + atomic_integral& operator=(atomic_integral const& rhs) { + n.store(rhs.n.load()); + return *this; + } +#else operator Integral()const{return n.load(std::memory_order_relaxed);} void operator=(Integral m){n.store(m,std::memory_order_relaxed);} void operator|=(Integral m){n.fetch_or(m,std::memory_order_relaxed);} @@ -214,6 +225,7 @@ struct atomic_integral n.store(rhs.n.load(std::memory_order_relaxed),std::memory_order_relaxed); return *this; } +#endif std::atomic n; };