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 70e70c5d070cf0fadc6f8764f2a9ab8c4a76e94d..795ed4217d356fd50da22274358750c176fd1793 100644 (file)
@@ -249,7 +249,7 @@ namespace cds { namespace gc {
                 atomics::atomic<size_t>              m_nItemCount;   ///< buffer's item count
 
             public:
                 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)
                 {}
                     : 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
             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
 
             /// 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
 
             /// 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
 
         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;
 
             /// 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( 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
 
             /// Returns the capacity of array
             CDS_CONSTEXPR size_t capacity() const CDS_NOEXCEPT
index 0f31ce3140e200389f705c5bde1243b1b725dac0..9fd8c8a05b5cea05a99dccd0de3e90030e3992e3 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>
                 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;
             {
                 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>
                 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 {
             {
                 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
         /// 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;
         }
 
             return true;
         }
 
index 2524ddb91e6087d5f6149da6af4a11001510d17a..89b9cb9791bbdded1de27b7aed748f441aeba272 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>
                 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;
             {
                 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>
                 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 {
             {
                 T pRet;
                 do {
index ccabd381d66ceeae3a2d9ad4f9b6784cf7449cc8..1c43b4a01f4e12596589b5158d90a895e2924806 100644 (file)
@@ -24,12 +24,12 @@ namespace cds { namespace gc {
             cds::threading::Manager::detachThread();
     }
 
             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>
         : 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>() )
     {}
 
         : GuardArray::base_class( cds::threading::getGC<HP>() )
     {}
 
index f3c9814e44c8dec51176158b3969fbbd42b6c808..f886f51f36e853ab7231aa850f51824b7160e4ab 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" )
         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" )
         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()) {
         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;
             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:
             std::cout << "Use classic scan strategy for Hazard Pointer memory reclamation algorithm\n";
             break;
         default: