X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=cds%2Fintrusive%2Fdetails%2Fsingle_link_struct.h;h=b235b593e7775c798ec6cda434c20aa1f9d1cdd9;hb=a01ecc87dadf753538d4c22feb98f7e00a66a4d1;hp=86363980be1458f982693ec5311aa65da8d798f3;hpb=8be59b70a3697023d33f7a7d3831d2875658645a;p=libcds.git diff --git a/cds/intrusive/details/single_link_struct.h b/cds/intrusive/details/single_link_struct.h index 86363980..b235b593 100644 --- a/cds/intrusive/details/single_link_struct.h +++ b/cds/intrusive/details/single_link_struct.h @@ -1,12 +1,11 @@ //$$CDS-header$$ -#ifndef __CDS_INTRUSIVE_DETAILS_SINGLE_LINK_STRUCT_H -#define __CDS_INTRUSIVE_DETAILS_SINGLE_LINK_STRUCT_H +#ifndef CDSLIB_INTRUSIVE_DETAILS_SINGLE_LINK_STRUCT_H +#define CDSLIB_INTRUSIVE_DETAILS_SINGLE_LINK_STRUCT_H #include #include -#include -#include +#include namespace cds { namespace intrusive { @@ -22,7 +21,7 @@ namespace cds { namespace intrusive { - Tag - a tag used to distinguish between different implementation */ template - struct node: public GC::container_node + struct node { typedef GC gc ; ///< Garbage collector typedef Tag tag ; ///< tag @@ -37,57 +36,11 @@ namespace cds { namespace intrusive { atomic_node_ptr m_pNext ; ///< pointer to the next node in the container - node() - : m_pNext( nullptr ) - {} - }; - - //@cond - // Specialization for HRC GC - template - struct node< gc::HRC, Tag>: public gc::HRC::container_node - { - typedef gc::HRC gc ; ///< Garbage collector - typedef Tag tag ; ///< tag - - typedef gc::atomic_ref atomic_node_ptr ; ///< atomic pointer - atomic_node_ptr m_pNext ; ///< pointer to the next node in the container - - node() - : m_pNext( nullptr ) - {} - - protected: - virtual void cleanUp( cds::gc::hrc::ThreadGC * pGC ) - { - assert( pGC != nullptr ); - typename gc::GuardArray<2> aGuards( *pGC ); - - while ( true ) { - node * pNext = aGuards.protect( 0, m_pNext ); - if ( pNext && pNext->m_bDeleted.load(atomics::memory_order_acquire) ) { - node * p = aGuards.protect( 1, pNext->m_pNext ); - m_pNext.compare_exchange_strong( pNext, p, atomics::memory_order_acquire, atomics::memory_order_relaxed ); - continue; - } - else { - break; - } - } - } - - virtual void terminate( cds::gc::hrc::ThreadGC * pGC, bool bConcurrent ) + node() CDS_NOEXCEPT { - if ( bConcurrent ) { - node * pNext = m_pNext.load(atomics::memory_order_relaxed); - do {} while ( !m_pNext.compare_exchange_weak( pNext, nullptr, atomics::memory_order_release, atomics::memory_order_relaxed ) ); - } - else { - m_pNext.store( nullptr, atomics::memory_order_relaxed ); - } + m_pNext.store( nullptr, atomics::memory_order_release ); } }; - //@endcond //@cond struct default_hook { @@ -104,11 +57,10 @@ namespace cds { namespace intrusive { typedef typename options::gc gc; typedef typename options::tag tag; typedef node node_type; - typedef HookType hook_type; + typedef HookType hook_type; }; //@endcond - /// Base hook /** \p Options are: @@ -167,6 +119,7 @@ namespace cds { namespace intrusive { static void is_empty( const node_type * pNode ) { assert( pNode->m_pNext.load( atomics::memory_order_relaxed ) == nullptr ); + CDS_UNUSED( pNode ); } }; @@ -174,18 +127,6 @@ namespace cds { namespace intrusive { template struct link_checker_selector; - template - struct link_checker_selector< gc::HRC, Node, opt::never_check_link > - { - typedef link_checker type; - }; - - template - struct link_checker_selector< gc::HRC, Node, opt::debug_check_link > - { - typedef link_checker type; - }; - template struct link_checker_selector< GC, Node, opt::never_check_link > { @@ -224,4 +165,4 @@ namespace cds { namespace intrusive { -#endif // #ifndef __CDS_INTRUSIVE_DETAILS_SINGLE_LINK_STRUCT_H +#endif // #ifndef CDSLIB_INTRUSIVE_DETAILS_SINGLE_LINK_STRUCT_H