From b8d9605107eea3d7b3a893bdaa540cef031b9810 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Mon, 11 Dec 2023 19:43:05 +0100 Subject: [PATCH] fine-tuned memory order for metadata manipulation --- include/boost/unordered/detail/foa/concurrent_table.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/unordered/detail/foa/concurrent_table.hpp b/include/boost/unordered/detail/foa/concurrent_table.hpp index 6186d9d7..a19370ab 100644 --- a/include/boost/unordered/detail/foa/concurrent_table.hpp +++ b/include/boost/unordered/detail/foa/concurrent_table.hpp @@ -206,8 +206,8 @@ template struct atomic_integral { #if defined(BOOST_UNORDERED_LATCH_FREE) - operator Integral()const{return n.load();} - void operator=(Integral m){n.store(m);} + operator Integral()const{return n.load(std::memory_order_acquire);} + void operator=(Integral m){n.store(m,std::memory_order_release);} void operator|=(Integral m){n.fetch_or(m);} void operator&=(Integral m){n.fetch_and(m);} @@ -1564,6 +1564,8 @@ private: goto startover; } auto lck=access(group_exclusive{},pos0); + reinterpret_cast*>(pg)[n]. + load(std::memory_order_acquire); if(BOOST_UNLIKELY(insert_counter(pos0)!=counter)){ /* other thread inserted from pos0, need to start over */ pg->reset(n);