From 72a82a57dd0555a3d6eecaa8a673c96b796c51e4 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 23 May 2015 18:12:56 +0300 Subject: [PATCH] Fixed refactoring bugs --- cds/intrusive/details/michael_list_base.h | 4 ++-- cds/intrusive/michael_list_rcu.h | 14 +++++++++----- cds/urcu/raw_ptr.h | 1 - 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cds/intrusive/details/michael_list_base.h b/cds/intrusive/details/michael_list_base.h index bcafce1e..c7e3e264 100644 --- a/cds/intrusive/details/michael_list_base.h +++ b/cds/intrusive/details/michael_list_base.h @@ -28,8 +28,8 @@ namespace cds { namespace intrusive { typedef GC gc ; ///< Garbage collector typedef Tag tag ; ///< tag - typedef cds::details::marked_ptr marked_ptr ; ///< marked pointer - typedef typename gc::template atomic_marked_ptr< marked_ptr> atomic_marked_ptr ; ///< atomic marked pointer specific for GC + typedef cds::details::marked_ptr marked_ptr; ///< marked pointer + typedef typename gc::template atomic_marked_ptr atomic_marked_ptr; ///< atomic marked pointer specific for GC atomic_marked_ptr m_pNext ; ///< pointer to the next node in the container diff --git a/cds/intrusive/michael_list_rcu.h b/cds/intrusive/michael_list_rcu.h index e3473d2b..577485b2 100644 --- a/cds/intrusive/michael_list_rcu.h +++ b/cds/intrusive/michael_list_rcu.h @@ -22,10 +22,10 @@ namespace cds { namespace intrusive { typedef cds::urcu::gc< RCU > gc; ///< Garbage collector typedef Tag tag; ///< tag - typedef cds::details::marked_ptr marked_ptr ; ///< marked pointer - typedef typename gc::template atomic_marked_ptr< marked_ptr> atomic_marked_ptr ; ///< atomic marked pointer specific for GC + typedef cds::details::marked_ptr marked_ptr; ///< marked pointer + typedef typename gc::template atomic_marked_ptr atomic_marked_ptr; ///< atomic marked pointer specific for GC - atomic_marked_ptr m_pNext ; ///< pointer to the next node in the container + atomic_marked_ptr m_pNext; ///< pointer to the next node in the container node * m_pDelChain; ///< Deleted node chain (local for a thread) CDS_CONSTEXPR node() CDS_NOEXCEPT @@ -158,8 +158,11 @@ namespace cds { namespace intrusive { auto f = [&pChain]() -> cds::urcu::retired_ptr { node_type * p = pChain; - pChain = p->m_pDelChain; - return cds::urcu::make_retired_ptr( node_traits::to_value_ptr( p )); + if ( p ) { + pChain = p->m_pDelChain; + return cds::urcu::make_retired_ptr( node_traits::to_value_ptr( p )); + } + return cds::urcu::make_retired_ptr( static_cast(nullptr)); }; gc::batch_retire(std::ref(f)); } @@ -222,6 +225,7 @@ namespace cds { namespace intrusive { void apply() { if ( pReclaimedChain ) { + assert( !gc::is_locked()); dispose_chain( pReclaimedChain ); pReclaimedChain = nullptr; } diff --git a/cds/urcu/raw_ptr.h b/cds/urcu/raw_ptr.h index ea8f98eb..c4d0f1c1 100644 --- a/cds/urcu/raw_ptr.h +++ b/cds/urcu/raw_ptr.h @@ -164,7 +164,6 @@ namespace cds { namespace urcu { */ void release() { - assert( !rcu::is_locked() ); m_Enum.apply(); m_ptr = nullptr; } -- 2.34.1