diff --git a/include/boost/unordered/detail/foa/concurrent_table.hpp b/include/boost/unordered/detail/foa/concurrent_table.hpp index b79f70c6..7fc397cc 100644 --- a/include/boost/unordered/detail/foa/concurrent_table.hpp +++ b/include/boost/unordered/detail/foa/concurrent_table.hpp @@ -840,8 +840,7 @@ private: using multimutex_type=multimutex; // TODO: adapt 128 to the machine using shared_lock_guard=reentrancy_checked>; using exclusive_lock_guard=reentrancy_checked>; - using exclusive_bilock_guard= - reentrancy_checked>>; + using exclusive_bilock_guard=reentrancy_bichecked>; using group_shared_lock_guard=typename group_access::shared_lock_guard; using group_exclusive_lock_guard=typename group_access::exclusive_lock_guard; using group_insert_counter_type=typename group_access::insert_counter_type; diff --git a/include/boost/unordered/detail/foa/reentrancy_check.hpp b/include/boost/unordered/detail/foa/reentrancy_check.hpp index 6db39f1a..b0e65c64 100644 --- a/include/boost/unordered/detail/foa/reentrancy_check.hpp +++ b/include/boost/unordered/detail/foa/reentrancy_check.hpp @@ -56,10 +56,11 @@ class entry_trace public: entry_trace(const void* px_):px{px_} { - BOOST_ASSERT(px!=nullptr); - BOOST_UNORDERED_REENTRANCY_CHECK_ASSERT_MSG( - !find(px),"reentrancy not allowed"); - header()=this; + if(px){ + BOOST_UNORDERED_REENTRANCY_CHECK_ASSERT_MSG( + !find(px),"reentrancy not allowed"); + header()=this; + } } /* not used but VS in pre-C++17 mode needs to see it for RVO */ @@ -111,6 +112,24 @@ struct reentrancy_checked LockGuard lck; }; +template +struct reentrancy_bichecked +{ + template + reentrancy_bichecked(const void* px,const void* py,Args&&... args): + tr1{px},tr2{py!=px?py:nullptr},lck{std::forward(args)...}{} + + void unlock() + { + lck.unlock(); + tr2.clear(); + tr1.clear(); + } + + entry_trace tr1,tr2; + LockGuard lck; +}; + #else template @@ -125,6 +144,18 @@ struct reentrancy_checked LockGuard lck; }; +template +struct reentrancy_bichecked +{ + template + reentrancy_bichecked(const void*,const void*,Args&&... args): + lck{std::forward(args)...}{} + + void unlock(){lck.unlock();} + + LockGuard lck; +}; + #endif } /* namespace foa */