From 21b192b1c2cd0d8cb1ccc9e3b6f5d9354dd99e00 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 15 Nov 2014 21:52:07 +0300 Subject: [PATCH] Fix GC refactoring bugs --- cds/gc/details/dhp.h | 10 +++++----- cds/gc/impl/dhp_decl.h | 15 ++++++++++----- cds/gc/impl/hp_decl.h | 4 ++-- cds/gc/impl/hp_impl.h | 4 ++-- tests/cppunit/test_main.cpp | 8 ++++---- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/cds/gc/details/dhp.h b/cds/gc/details/dhp.h index 70e70c5d..795ed421 100644 --- a/cds/gc/details/dhp.h +++ b/cds/gc/details/dhp.h @@ -249,7 +249,7 @@ namespace cds { namespace gc { atomics::atomic 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 diff --git a/cds/gc/impl/dhp_decl.h b/cds/gc/impl/dhp_decl.h index 0f31ce31..9fd8c8a0 100644 --- a/cds/gc/impl/dhp_decl.h +++ b/cds/gc/impl/dhp_decl.h @@ -155,7 +155,7 @@ namespace cds { namespace gc { Really, the result of f( toGuard.load() ) is assigned to the hazard pointer. */ template - T protect( atomics::atomic const& toGuard, Func f ) CDS_NOEXCEPT_( f( toGuard.load( atomics::memory_order_relaxed ))) + T protect( atomics::atomic const& toGuard, Func f ) CDS_NOEXCEPT_( noexcept( Func( atomics::atomic().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 f( toGuard.load() ) is assigned to the hazard pointer. */ template - T protect( size_t nIndex, atomics::atomic const& toGuard, Func f ) CDS_NOEXCEPT_( f( toGuard.load( atomics::memory_order_relaxed ))) + T protect( size_t nIndex, atomics::atomic const& toGuard, Func f ) CDS_NOEXCEPT_( noexcept( Func( atomics::atomic().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; } diff --git a/cds/gc/impl/hp_decl.h b/cds/gc/impl/hp_decl.h index 2524ddb9..89b9cb97 100644 --- a/cds/gc/impl/hp_decl.h +++ b/cds/gc/impl/hp_decl.h @@ -153,7 +153,7 @@ namespace cds { namespace gc { Really, the result of f( toGuard.load() ) is assigned to the hazard pointer. */ template - T protect( atomics::atomic const& toGuard, Func f ) CDS_NOEXCEPT_( f( toGuard.load( atomics::memory_order_relaxed ) ) ) + T protect( atomics::atomic const& toGuard, Func f ) CDS_NOEXCEPT_( noexcept( Func( atomics::atomic().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 f( toGuard.load() ) is assigned to the hazard pointer. */ template - T protect( size_t nIndex, atomics::atomic const& toGuard, Func f ) CDS_NOEXCEPT_( f( toGuard.load( atomics::memory_order_acquire ))) + T protect( size_t nIndex, atomics::atomic const& toGuard, Func f ) CDS_NOEXCEPT_( noexcept( Func( atomics::atomic().load(atomics::memory_order_relaxed)))) { T pRet; do { diff --git a/cds/gc/impl/hp_impl.h b/cds/gc/impl/hp_impl.h index ccabd381..1c43b4a0 100644 --- a/cds/gc/impl/hp_impl.h +++ b/cds/gc/impl/hp_impl.h @@ -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() ) {} template - inline HP::GuardArray::GuardArray() CDS_CONSTEXPR + inline HP::GuardArray::GuardArray() CDS_NOEXCEPT : GuardArray::base_class( cds::threading::getGC() ) {} diff --git a/tests/cppunit/test_main.cpp b/tests/cppunit/test_main.cpp index f3c9814e..f886f51f 100644 --- a/tests/cppunit/test_main.cpp +++ b/tests/cppunit/test_main.cpp @@ -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: -- 2.34.1