Changed: use padding option instead of alignment one
[libcds.git] / cds / intrusive / details / single_link_struct.h
index 8796e35c0709806a25d95ab4d9af16184adf1041..b235b593e7775c798ec6cda434c20aa1f9d1cdd9 100644 (file)
@@ -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 <cds/intrusive/details/base.h>
 #include <cds/gc/default_gc.h>
-#include <cds/cxx11_atomic.h>
-#include <cds/gc/hrc.h>
+#include <cds/algo/atomic.h>
 
 namespace cds { namespace intrusive {
 
@@ -22,7 +21,7 @@ namespace cds { namespace intrusive {
             - Tag - a tag used to distinguish between different implementation
         */
         template <class GC, typename Tag = opt::none>
-        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 <typename Tag>
-        struct node< gc::HRC, Tag>: public gc::HRC::container_node
-        {
-            typedef gc::HRC     gc  ;   ///< Garbage collector
-            typedef Tag         tag ;   ///< tag
-
-            typedef gc::atomic_ref<node>    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 {
@@ -108,7 +61,6 @@ namespace cds { namespace intrusive {
         };
         //@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 <class GC, typename Node, opt::link_check_type LinkType >
         struct link_checker_selector;
 
-        template <typename Node>
-        struct link_checker_selector< gc::HRC, Node, opt::never_check_link >
-        {
-            typedef link_checker<Node>  type;
-        };
-
-        template <typename Node>
-        struct link_checker_selector< gc::HRC, Node, opt::debug_check_link >
-        {
-            typedef link_checker<Node>  type;
-        };
-
         template <typename GC, typename Node>
         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