refresh changelog
[libcds.git] / src / ptb_gc.cpp
index 12ceb7f9c33a146288e4a2e1136b4804cc3eeb83..59a149c29221d5091ab78ab06bf95911662cccb3 100644 (file)
@@ -2,11 +2,11 @@
 
 // Pass The Buck (PTB) Memory manager implementation
 
-#include <cds/gc/ptb/ptb.h>
-#include <cds/int_algo.h>
-
-#include <cds/details/hash_functor_selector.h>
 #include <algorithm>   // std::fill
+#include <functional>  // std::hash
+
+#include <cds/gc/ptb/ptb.h>
+#include <cds/algo/int_algo.h>
 
 namespace cds { namespace gc { namespace ptb {
 
@@ -25,7 +25,7 @@ namespace cds { namespace gc { namespace ptb {
             }
             item_type&  bucket( guard_data::guarded_ptr p )
             {
-                return m_Buckets[ cds::details::hash<guard_data::guarded_ptr>()( p ) & (m_nBucketCount - 1)  ];
+                return m_Buckets[ std::hash<guard_data::guarded_ptr>()( p ) & (m_nBucketCount - 1)  ];
             }
 
         public:
@@ -133,7 +133,7 @@ namespace cds { namespace gc { namespace ptb {
         };
     }
 
-    GarbageCollector * GarbageCollector::m_pManager = NULL;
+    GarbageCollector * GarbageCollector::m_pManager = nullptr;
 
     void CDS_STDCALL GarbageCollector::Construct(
         size_t nLiberateThreshold
@@ -149,7 +149,7 @@ namespace cds { namespace gc { namespace ptb {
     {
         if ( m_pManager ) {
             delete m_pManager;
-            m_pManager = NULL;
+            m_pManager = nullptr;
         }
     }
 
@@ -168,7 +168,7 @@ namespace cds { namespace gc { namespace ptb {
         details::retired_ptr_node * pHead = nullptr;
         details::retired_ptr_node * pTail = nullptr;
 
-        for ( details::guard_data * pGuard = m_GuardPool.begin(); pGuard; pGuard = pGuard->pGlobalNext.load(CDS_ATOMIC::memory_order_relaxed)) {
+        for ( details::guard_data * pGuard = m_GuardPool.begin(); pGuard; pGuard = pGuard->pGlobalNext.load(atomics::memory_order_relaxed)) {
             details::guard_data::handoff_ptr h = pGuard->pHandOff;
             pGuard->pHandOff  = nullptr;
             while ( h ) {
@@ -192,7 +192,7 @@ namespace cds { namespace gc { namespace ptb {
         details::retired_ptr_buffer::privatize_result retiredList = m_RetiredBuffer.privatize();
         if ( retiredList.first ) {
 
-            size_t nLiberateThreshold = m_nLiberateThreshold.load(CDS_ATOMIC::memory_order_relaxed);
+            size_t nLiberateThreshold = m_nLiberateThreshold.load(atomics::memory_order_relaxed);
             details::liberate_set set( beans::ceil2( retiredList.second > nLiberateThreshold ? retiredList.second : nLiberateThreshold ) );
 
             // Get list of retired pointers
@@ -205,10 +205,10 @@ namespace cds { namespace gc { namespace ptb {
             }
 
             // Liberate cycle
-            for ( details::guard_data * pGuard = m_GuardPool.begin(); pGuard; pGuard = pGuard->pGlobalNext.load(CDS_ATOMIC::memory_order_acquire) )
+            for ( details::guard_data * pGuard = m_GuardPool.begin(); pGuard; pGuard = pGuard->pGlobalNext.load(atomics::memory_order_acquire) )
             {
                 // get guarded pointer
-                details::guard_data::guarded_ptr  valGuarded = pGuard->pPost.load(CDS_ATOMIC::memory_order_acquire);
+                details::guard_data::guarded_ptr  valGuarded = pGuard->pPost.load(atomics::memory_order_acquire);
 
                 if ( valGuarded ) {
                     details::retired_ptr_node * pRetired = set.erase( valGuarded );
@@ -237,7 +237,7 @@ namespace cds { namespace gc { namespace ptb {
             }
             else {
                 // liberate cycle did not free any retired pointer - double liberate threshold
-                m_nLiberateThreshold.compare_exchange_strong( nLiberateThreshold, nLiberateThreshold * 2, CDS_ATOMIC::memory_order_release, CDS_ATOMIC::memory_order_relaxed );
+                m_nLiberateThreshold.compare_exchange_strong( nLiberateThreshold, nLiberateThreshold * 2, atomics::memory_order_release, atomics::memory_order_relaxed );
             }
         }
     }
@@ -247,10 +247,10 @@ namespace cds { namespace gc { namespace ptb {
     {
         details::guard_data::handoff_ptr const nullHandOff = nullptr;
 
-        for ( details::guard_data * pGuard = m_GuardPool.begin(); pGuard; pGuard = pGuard->pGlobalNext.load(CDS_ATOMIC::memory_order_acquire) )
+        for ( details::guard_data * pGuard = m_GuardPool.begin(); pGuard; pGuard = pGuard->pGlobalNext.load(atomics::memory_order_acquire) )
         {
             // get guarded pointer
-            details::guard_data::guarded_ptr  valGuarded = pGuard->pPost.load(CDS_ATOMIC::memory_order_acquire);
+            details::guard_data::guarded_ptr  valGuarded = pGuard->pPost.load(atomics::memory_order_acquire);
             details::guard_data::handoff_ptr h;
 
             if ( valGuarded ) {
@@ -263,7 +263,7 @@ namespace cds { namespace gc { namespace ptb {
 
                     // Now, try to set retired node pRetired as a hand-off node for the guard
                     cds::lock::Auto<details::guard_data::handoff_spin> al( pGuard->spinHandOff );
-                    if ( valGuarded == pGuard->pPost.load(CDS_ATOMIC::memory_order_acquire) ) {
+                    if ( valGuarded == pGuard->pPost.load(atomics::memory_order_acquire) ) {
                         if ( pGuard->pHandOff && pGuard->pHandOff->m_ptr.m_p == pRetired->m_ptr.m_p ) {
                             h = nullHandOff ; //nullptr;
                             details::retired_ptr_node * pTail = pGuard->pHandOff;