Fix GC refactoring bugs
authorkhizmax <libcds.dev@gmail.com>
Sat, 15 Nov 2014 18:52:07 +0000 (21:52 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sat, 15 Nov 2014 18:52:07 +0000 (21:52 +0300)
cds/gc/details/dhp.h
cds/gc/impl/dhp_decl.h
cds/gc/impl/hp_decl.h
cds/gc/impl/hp_impl.h
tests/cppunit/test_main.cpp

index 70e70c5..795ed42 100644 (file)
@@ -249,7 +249,7 @@ namespace cds { namespace gc {
                 atomics::atomic<size_t>              m_nItemCount;   ///< buffer's item count
 
             public:
-                CDS_CONSTEXPR retired_ptr_buffer() CDS_NOEXCEPT
+                retired_ptr_buffer() CDS_NOEXCEPT
                     : m_pHead( nullptr )
                     , m_nItemCount(0)
                 {}
@@ -543,10 +543,10 @@ namespace cds { namespace gc {
             ThreadGC&    m_gc    ;    ///< ThreadGC object of current thread
         public:
             /// Allocates a guard from \p gc GC. \p gc must be ThreadGC object of current thread
-            Guard( ThreadGC& gc ) CDS_NOEXCEPT;
+            Guard( ThreadGC& gc );
 
             /// Returns guard allocated back to pool of free guards
-            ~Guard() CDS_NOEXCEPT;    // inline after GarbageCollector
+            ~Guard();    // inline after GarbageCollector
 
             /// Returns DHP GC object
             ThreadGC& getGC() CDS_NOEXCEPT
@@ -588,7 +588,7 @@ namespace cds { namespace gc {
 
         public:
             /// Allocates array of guards from \p gc which must be the ThreadGC object of current thread
-            GuardArray( ThreadGC& gc ) CDS_NOEXCEPT;    // inline below
+            GuardArray( ThreadGC& gc );    // inline below
 
             /// The object is not default-constructible
             GuardArray() = delete;
@@ -597,7 +597,7 @@ namespace cds { namespace gc {
             GuardArray( GuardArray const& ) = delete;
 
             /// Returns guards allocated back to pool
-            ~GuardArray() CDS_NOEXCEPT;    // inline below
+            ~GuardArray();    // inline below
 
             /// Returns the capacity of array
             CDS_CONSTEXPR size_t capacity() const CDS_NOEXCEPT
index 0f31ce3..9fd8c8a 100644 (file)
@@ -155,7 +155,7 @@ namespace cds { namespace gc {
                 Really, the result of <tt> f( toGuard.load() ) </tt> is assigned to the hazard pointer.
             */
             template <typename T, class Func>
-            T protect( atomics::atomic<T> const& toGuard, Func f ) CDS_NOEXCEPT_( f( toGuard.load( atomics::memory_order_relaxed )))
+            T protect( atomics::atomic<T> const& toGuard, Func f ) CDS_NOEXCEPT_( noexcept( Func( atomics::atomic<T>().load(atomics::memory_order_relaxed))))
             {
                 T pCur = toGuard.load(atomics::memory_order_relaxed);
                 T pRet;
@@ -293,7 +293,7 @@ namespace cds { namespace gc {
                 Actually, the result of <tt> f( toGuard.load() ) </tt> is assigned to the hazard pointer.
             */
             template <typename T, class Func>
-            T protect( size_t nIndex, atomics::atomic<T> const& toGuard, Func f ) CDS_NOEXCEPT_( f( toGuard.load( atomics::memory_order_relaxed )))
+            T protect( size_t nIndex, atomics::atomic<T> const& toGuard, Func f ) CDS_NOEXCEPT_( noexcept( Func( atomics::atomic<T>().load(atomics::memory_order_relaxed))))
             {
                 T pRet;
                 do {
@@ -393,11 +393,16 @@ namespace cds { namespace gc {
         /// Checks if count of hazard pointer is no less than \p nCountNeeded
         /**
             The function always returns \p true since the guard count is unlimited for
-            DHP garbage collector.
+            \p gc::DHP garbage collector.
         */
-        static CDS_CONSTEXPR bool check_available_guards( size_t nCountNeeded, bool /*bRaiseException*/ = true )
+        static CDS_CONSTEXPR bool check_available_guards( 
+#ifdef CDS_DOXYGEN_INVOKED
+            size_t nCountNeeded, 
+#else
+            size_t,
+#endif
+            bool /*bRaiseException*/ = true )
         {
-            CDS_UNUSED( nCountNeeded );
             return true;
         }
 
index 2524ddb..89b9cb9 100644 (file)
@@ -153,7 +153,7 @@ namespace cds { namespace gc {
                 Really, the result of <tt> f( toGuard.load() ) </tt> is assigned to the hazard pointer.
             */
             template <typename T, class Func>
-            T protect( atomics::atomic<T> const& toGuard, Func f ) CDS_NOEXCEPT_( f( toGuard.load( atomics::memory_order_relaxed ) ) )
+            T protect( atomics::atomic<T> const& toGuard, Func f ) CDS_NOEXCEPT_( noexcept( Func( atomics::atomic<T>().load(atomics::memory_order_relaxed))))
             {
                 T pCur = toGuard.load(atomics::memory_order_relaxed);
                 T pRet;
@@ -289,7 +289,7 @@ namespace cds { namespace gc {
                 Really, the result of <tt> f( toGuard.load() ) </tt> is assigned to the hazard pointer.
             */
             template <typename T, class Func>
-            T protect( size_t nIndex, atomics::atomic<T> const& toGuard, Func f ) CDS_NOEXCEPT_( f( toGuard.load( atomics::memory_order_acquire )))
+            T protect( size_t nIndex, atomics::atomic<T> const& toGuard, Func f ) CDS_NOEXCEPT_( noexcept( Func( atomics::atomic<T>().load(atomics::memory_order_relaxed))))
             {
                 T pRet;
                 do {
index ccabd38..1c43b4a 100644 (file)
@@ -24,12 +24,12 @@ namespace cds { namespace gc {
             cds::threading::Manager::detachThread();
     }
 
-    inline HP::Guard::Guard() CDS_CONSTEXPR
+    inline HP::Guard::Guard() CDS_NOEXCEPT
         : Guard::base_class( cds::threading::getGC<HP>() )
     {}
 
     template <size_t COUNT>
-    inline HP::GuardArray<COUNT>::GuardArray() CDS_CONSTEXPR
+    inline HP::GuardArray<COUNT>::GuardArray() CDS_NOEXCEPT
         : GuardArray::base_class( cds::threading::getGC<HP>() )
     {}
 
index f3c9814..f886f51 100644 (file)
@@ -363,18 +363,18 @@ int main(int argc, char** argv)
         CppUnitMini::TestCfg& cfg = CppUnitMini::TestCase::m_Cfg.get( "General" );
         std::string strHZPScanStrategy = cfg.get( "HZP_scan_strategy", std::string("classic") );
         if ( strHZPScanStrategy == "inplace" )
-            hzpGC.setScanType( cds::gc::hp::inplace );
+            hzpGC.setScanType( cds::gc::HP::scan_type::inplace );
         else if ( strHZPScanStrategy == "classic" )
-            hzpGC.setScanType( cds::gc::hp::classic );
+            hzpGC.setScanType( cds::gc::HP::scan_type::classic );
         else {
             std::cout << "Error value of HZP_scan_strategy in General section of test config\n";
         }
 
         switch (hzpGC.getScanType()) {
-        case cds::gc::hp::inplace:
+        case cds::gc::HP::scan_type::inplace:
             std::cout << "Use in-place scan strategy for Hazard Pointer memory reclamation algorithm\n";
             break;
-        case cds::gc::hp::classic:
+        case cds::gc::HP::scan_type::classic:
             std::cout << "Use classic scan strategy for Hazard Pointer memory reclamation algorithm\n";
             break;
         default: