forked from boostorg/unordered
fixed reentrancy checking for scoped_bilock
This commit is contained in:
@@ -840,8 +840,7 @@ private:
|
|||||||
using multimutex_type=multimutex<mutex_type,128>; // TODO: adapt 128 to the machine
|
using multimutex_type=multimutex<mutex_type,128>; // TODO: adapt 128 to the machine
|
||||||
using shared_lock_guard=reentrancy_checked<shared_lock<mutex_type>>;
|
using shared_lock_guard=reentrancy_checked<shared_lock<mutex_type>>;
|
||||||
using exclusive_lock_guard=reentrancy_checked<lock_guard<multimutex_type>>;
|
using exclusive_lock_guard=reentrancy_checked<lock_guard<multimutex_type>>;
|
||||||
using exclusive_bilock_guard=
|
using exclusive_bilock_guard=reentrancy_bichecked<scoped_bilock<multimutex_type>>;
|
||||||
reentrancy_checked<reentrancy_checked<scoped_bilock<multimutex_type>>>;
|
|
||||||
using group_shared_lock_guard=typename group_access::shared_lock_guard;
|
using group_shared_lock_guard=typename group_access::shared_lock_guard;
|
||||||
using group_exclusive_lock_guard=typename group_access::exclusive_lock_guard;
|
using group_exclusive_lock_guard=typename group_access::exclusive_lock_guard;
|
||||||
using group_insert_counter_type=typename group_access::insert_counter_type;
|
using group_insert_counter_type=typename group_access::insert_counter_type;
|
||||||
|
@@ -56,11 +56,12 @@ class entry_trace
|
|||||||
public:
|
public:
|
||||||
entry_trace(const void* px_):px{px_}
|
entry_trace(const void* px_):px{px_}
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(px!=nullptr);
|
if(px){
|
||||||
BOOST_UNORDERED_REENTRANCY_CHECK_ASSERT_MSG(
|
BOOST_UNORDERED_REENTRANCY_CHECK_ASSERT_MSG(
|
||||||
!find(px),"reentrancy not allowed");
|
!find(px),"reentrancy not allowed");
|
||||||
header()=this;
|
header()=this;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* not used but VS in pre-C++17 mode needs to see it for RVO */
|
/* not used but VS in pre-C++17 mode needs to see it for RVO */
|
||||||
entry_trace(const entry_trace&);
|
entry_trace(const entry_trace&);
|
||||||
@@ -111,6 +112,24 @@ struct reentrancy_checked
|
|||||||
LockGuard lck;
|
LockGuard lck;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename LockGuard>
|
||||||
|
struct reentrancy_bichecked
|
||||||
|
{
|
||||||
|
template<typename... Args>
|
||||||
|
reentrancy_bichecked(const void* px,const void* py,Args&&... args):
|
||||||
|
tr1{px},tr2{py!=px?py:nullptr},lck{std::forward<Args>(args)...}{}
|
||||||
|
|
||||||
|
void unlock()
|
||||||
|
{
|
||||||
|
lck.unlock();
|
||||||
|
tr2.clear();
|
||||||
|
tr1.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
entry_trace tr1,tr2;
|
||||||
|
LockGuard lck;
|
||||||
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
template<typename LockGuard>
|
template<typename LockGuard>
|
||||||
@@ -125,6 +144,18 @@ struct reentrancy_checked
|
|||||||
LockGuard lck;
|
LockGuard lck;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename LockGuard>
|
||||||
|
struct reentrancy_bichecked
|
||||||
|
{
|
||||||
|
template<typename... Args>
|
||||||
|
reentrancy_bichecked(const void*,const void*,Args&&... args):
|
||||||
|
lck{std::forward<Args>(args)...}{}
|
||||||
|
|
||||||
|
void unlock(){lck.unlock();}
|
||||||
|
|
||||||
|
LockGuard lck;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} /* namespace foa */
|
} /* namespace foa */
|
||||||
|
Reference in New Issue
Block a user