From 9c5aae5c490d06a8fbc367dd9878b8af38325ca1 Mon Sep 17 00:00:00 2001 From: khizmax Date: Fri, 14 Nov 2014 18:52:01 +0300 Subject: [PATCH 1/1] rename cds::gc::hzp namespace to cds::gc::hp --- cds/gc/dhp.h | 2 ++ cds/gc/hp/details/hp_alloc.h | 4 +-- cds/gc/hp/details/hp_fwd.h | 2 +- cds/gc/hp/details/hp_inline.h | 8 +++--- cds/gc/hp/details/hp_retired.h | 8 +++--- cds/gc/hp/details/hp_type.h | 2 +- cds/gc/hp/hp.h | 16 ++++++------ cds/gc/hp/hp_decl.h | 46 +++++++++++++++++----------------- src/hp_const.h | 4 +-- src/hp_gc.cpp | 4 +-- tests/cppunit/test_main.cpp | 18 ++++++------- 11 files changed, 58 insertions(+), 56 deletions(-) diff --git a/cds/gc/dhp.h b/cds/gc/dhp.h index fe3ff4b6..c854b91a 100644 --- a/cds/gc/dhp.h +++ b/cds/gc/dhp.h @@ -7,8 +7,10 @@ #include #include +//@cond namespace cds { namespace gc { typedef PTB DHP; }} // namespace cds::gc +//@endcond #endif // #ifndef __CDS_GC_DHP_H diff --git a/cds/gc/hp/details/hp_alloc.h b/cds/gc/hp/details/hp_alloc.h index 637d0344..b706850f 100644 --- a/cds/gc/hp/details/hp_alloc.h +++ b/cds/gc/hp/details/hp_alloc.h @@ -10,7 +10,7 @@ //@cond namespace cds { - namespace gc { namespace hzp { + namespace gc { namespace hp { /// Hazard Pointer schema implementation details namespace details { @@ -317,7 +317,7 @@ namespace cds { //@endcond }; - }}} // namespace gc::hzp::details + }}} // namespace gc::hp::details } // namespace cds //@endcond diff --git a/cds/gc/hp/details/hp_fwd.h b/cds/gc/hp/details/hp_fwd.h index 4cd723c5..9b7fcbdf 100644 --- a/cds/gc/hp/details/hp_fwd.h +++ b/cds/gc/hp/details/hp_fwd.h @@ -4,7 +4,7 @@ #define __CDS_GC_HP_DETAILS_HP_FWD_H namespace cds { - namespace gc { namespace hzp { + namespace gc { namespace hp { // forward declarations class GarbageCollector; diff --git a/cds/gc/hp/details/hp_inline.h b/cds/gc/hp/details/hp_inline.h index ec0bf103..741d7340 100644 --- a/cds/gc/hp/details/hp_inline.h +++ b/cds/gc/hp/details/hp_inline.h @@ -4,22 +4,22 @@ #define __CDS_GC_HP_DETAILS_HP_INLINE_H namespace cds { - namespace gc{ namespace hzp { namespace details { + namespace gc{ namespace hp { namespace details { /************************************************************************/ /* INLINES */ /************************************************************************/ - inline retired_vector::retired_vector( const cds::gc::hzp::GarbageCollector& HzpMgr ) + inline retired_vector::retired_vector( const cds::gc::hp::GarbageCollector& HzpMgr ) : m_arr( HzpMgr.getMaxRetiredPtrCount() ), m_nSize(0) {} - inline HPRec::HPRec( const cds::gc::hzp::GarbageCollector& HzpMgr ) + inline HPRec::HPRec( const cds::gc::hp::GarbageCollector& HzpMgr ) : m_hzp( HzpMgr.getHazardPointerCount() ), m_arrRetired( HzpMgr ) {} - } } } // namespace gc::hzp::details + } } } // namespace gc::hp::details } // namespace cds diff --git a/cds/gc/hp/details/hp_retired.h b/cds/gc/hp/details/hp_retired.h index 740e141d..ec0bacdb 100644 --- a/cds/gc/hp/details/hp_retired.h +++ b/cds/gc/hp/details/hp_retired.h @@ -9,7 +9,7 @@ #include namespace cds { - namespace gc{ namespace hzp { namespace details { + namespace gc{ namespace hp { namespace details { /// Retired pointer typedef cds::gc::details::retired_ptr retired_ptr; @@ -34,13 +34,13 @@ namespace cds { typedef retired_vector_impl::iterator iterator; /// Constructor - retired_vector( const cds::gc::hzp::GarbageCollector& HzpMgr ) ; // inline + retired_vector( const cds::gc::hp::GarbageCollector& HzpMgr ); // inline ~retired_vector() {} /// Vector capacity. /** - The capacity is constant for any thread. It is defined by cds::gc::hzp::GarbageCollector. + The capacity is constant for any thread. It is defined by cds::gc::hp::GarbageCollector. */ size_t capacity() const { return m_arr.capacity(); } @@ -80,7 +80,7 @@ namespace cds { } }; - } } } // namespace gc::hzp::details + } } } // namespace gc::hp::details } // namespace cds #endif // #ifndef __CDS_GC_HP_DETAILS_HP_RETIRED_H diff --git a/cds/gc/hp/details/hp_type.h b/cds/gc/hp/details/hp_type.h index 2188a2a3..853f5e1a 100644 --- a/cds/gc/hp/details/hp_type.h +++ b/cds/gc/hp/details/hp_type.h @@ -7,7 +7,7 @@ namespace cds { namespace gc { - namespace hzp { + namespace hp { /// Hazard pointer typedef void * hazard_pointer; diff --git a/cds/gc/hp/hp.h b/cds/gc/hp/hp.h index 6300178d..30df8116 100644 --- a/cds/gc/hp/hp.h +++ b/cds/gc/hp/hp.h @@ -12,8 +12,8 @@ #if CDS_COMPILER == CDS_COMPILER_MSVC # pragma warning(push) - // warning C4251: 'cds::gc::hzp::GarbageCollector::m_pListHead' : class 'cds::cxx11_atomic::atomic' - // needs to have dll-interface to be used by clients of class 'cds::gc::hzp::GarbageCollector' + // warning C4251: 'cds::gc::hp::GarbageCollector::m_pListHead' : class 'cds::cxx11_atomic::atomic' + // needs to have dll-interface to be used by clients of class 'cds::gc::hp::GarbageCollector' # pragma warning(disable: 4251) #endif @@ -89,7 +89,7 @@ namespace cds { - [2004] Andrei Alexandrescy, Maged Michael "Lock-free Data Structures with Hazard Pointers" - The cds::gc::hzp namespace and its members are internal representation of Hazard Pointer GC and should not be used directly. + The cds::gc::hp namespace and its members are internal representation of Hazard Pointer GC and should not be used directly. Use cds::gc::HP class in your code. Hazard Pointer garbage collector is a singleton. The main user-level part of Hazard Pointer schema is @@ -97,7 +97,7 @@ namespace cds { by contructing cds::gc::HP object in beginning of your main(). See cds::gc::HP class for explanation. */ - namespace hzp { + namespace hp { namespace details { /// Hazard pointer record of the thread @@ -110,7 +110,7 @@ namespace cds { retired_vector m_arrRetired ; ///< Retired pointer array /// Ctor - HPRec( const cds::gc::hzp::GarbageCollector& HzpMgr ) ; // inline + HPRec( const cds::gc::hp::GarbageCollector& HzpMgr ); // inline ~HPRec() {} @@ -193,7 +193,7 @@ namespace cds { event_counter m_DeferredNode ; ///< Count of objects that cannot be deleted in Scan phase because of a hazard_pointer guards it }; - /// Internal list of cds::gc::hzp::details::HPRec + /// Internal list of cds::gc::hp::details::HPRec struct hplist_node: public details::HPRec { hplist_node * m_pNextNode ; ///< next hazard ptr record in list @@ -609,7 +609,7 @@ namespace cds { /// Auto-managed array of hazard pointers /** - This class is wrapper around cds::gc::hzp::details::HPArray class. + This class is wrapper around cds::gc::hp::details::HPArray class. \p Count is the size of HP array */ template @@ -642,7 +642,7 @@ namespace cds { ThreadGC& getGC() const { return m_mgr; } }; - } // namespace hzp + } // namespace hp }} // namespace cds::gc // Inlines diff --git a/cds/gc/hp/hp_decl.h b/cds/gc/hp/hp_decl.h index cc846ecd..44ef1d39 100644 --- a/cds/gc/hp/hp_decl.h +++ b/cds/gc/hp/hp_decl.h @@ -27,7 +27,7 @@ namespace cds { namespace gc { { public: /// Native guarded pointer type - typedef gc::hzp::hazard_pointer guarded_pointer; + typedef gc::hp::hazard_pointer guarded_pointer; /// Atomic reference /** @@ -48,9 +48,9 @@ namespace cds { namespace gc { template using atomic_type = atomics::atomic; /// Thread GC implementation for internal usage - typedef hzp::ThreadGC thread_gc_impl; + typedef hp::ThreadGC thread_gc_impl; - /// Wrapper for hzp::ThreadGC class + /// Wrapper for hp::ThreadGC class /** @headerfile cds/gc/hp.h This class performs automatically attaching/detaching Hazard Pointer GC @@ -86,12 +86,12 @@ namespace cds { namespace gc { /// Hazard Pointer guard /** @headerfile cds/gc/hp.h - This class is a wrapper for hzp::AutoHPGuard. + This class is a wrapper for hp::AutoHPGuard. */ - class Guard: public hzp::AutoHPGuard + class Guard : public hp::AutoHPGuard { //@cond - typedef hzp::AutoHPGuard base_class; + typedef hp::AutoHPGuard base_class; //@endcond public: @@ -206,14 +206,14 @@ namespace cds { namespace gc { /// Array of Hazard Pointer guards /** @headerfile cds/gc/hp.h - This class is a wrapper for hzp::AutoHPArray template. + This class is a wrapper for hp::AutoHPArray template. Template parameter \p Count defines the size of HP array. */ template - class GuardArray: public hzp::AutoHPArray + class GuardArray : public hp::AutoHPArray { //@cond - typedef hzp::AutoHPArray base_class; + typedef hp::AutoHPArray base_class; //@endcond public: /// Rebind array for other size \p Count2 @@ -333,7 +333,7 @@ namespace cds { namespace gc { }; public: - /// Initializes hzp::GarbageCollector singleton + /// Initializes hp::GarbageCollector singleton /** The constructor initializes GC singleton with passed parameters. If GC instance is not exist then the function creates the instance. @@ -351,10 +351,10 @@ namespace cds { namespace gc { size_t nHazardPtrCount = 0, ///< Hazard pointer count per thread size_t nMaxThreadCount = 0, ///< Max count of simultaneous working thread in your application size_t nMaxRetiredPtrCount = 0, ///< Capacity of the array of retired objects for the thread - hzp::scan_type nScanType = hzp::inplace ///< Scan type (see \ref hzp::scan_type enum) + hp::scan_type nScanType = hp::inplace ///< Scan type (see \ref hp::scan_type enum) ) { - hzp::GarbageCollector::Construct( + hp::GarbageCollector::Construct( nHazardPtrCount, nMaxThreadCount, nMaxRetiredPtrCount, @@ -364,11 +364,11 @@ namespace cds { namespace gc { /// Terminates GC singleton /** - The destructor calls \code hzp::GarbageCollector::Destruct( true ) \endcode + The destructor calls \code hp::GarbageCollector::Destruct( true ) \endcode */ ~HP() { - hzp::GarbageCollector::Destruct( true ); + hp::GarbageCollector::Destruct( true ); } /// Checks if count of hazard pointer is no less than \p nCountNeeded @@ -379,7 +379,7 @@ namespace cds { namespace gc { */ static bool check_available_guards( size_t nCountNeeded, bool bRaiseException = true ) { - if ( hzp::GarbageCollector::instance().getHazardPointerCount() < nCountNeeded ) { + if ( hp::GarbageCollector::instance().getHazardPointerCount() < nCountNeeded ) { if ( bRaiseException ) throw std::overflow_error( "Too few hazard pointers" ); return false; @@ -390,19 +390,19 @@ namespace cds { namespace gc { /// Returns max Hazard Pointer count size_t max_hazard_count() const { - return hzp::GarbageCollector::instance().getHazardPointerCount(); + return hp::GarbageCollector::instance().getHazardPointerCount(); } /// Returns max count of thread size_t max_thread_count() const { - return hzp::GarbageCollector::instance().getMaxThreadCount(); + return hp::GarbageCollector::instance().getMaxThreadCount(); } /// Returns capacity of retired pointer array size_t retired_array_capacity() const { - return hzp::GarbageCollector::instance().getMaxRetiredPtrCount(); + return hp::GarbageCollector::instance().getMaxRetiredPtrCount(); } /// Retire pointer \p p with function \p pFunc @@ -467,23 +467,23 @@ namespace cds { namespace gc { static void retire( T * p ) ; // inline in hp_impl.h /// Get current scan strategy - hzp::scan_type getScanType() const + hp::scan_type getScanType() const { - return hzp::GarbageCollector::instance().getScanType(); + return hp::GarbageCollector::instance().getScanType(); } /// Set current scan strategy void setScanType( - hzp::scan_type nScanType ///< new scan strategy + hp::scan_type nScanType ///< new scan strategy ) { - hzp::GarbageCollector::instance().setScanType( nScanType ); + hp::GarbageCollector::instance().setScanType( nScanType ); } /// Checks if Hazard Pointer GC is constructed and may be used static bool isUsed() { - return hzp::GarbageCollector::isUsed(); + return hp::GarbageCollector::isUsed(); } diff --git a/src/hp_const.h b/src/hp_const.h index 71359d95..279b43f6 100644 --- a/src/hp_const.h +++ b/src/hp_const.h @@ -17,13 +17,13 @@ namespace cds { namespace gc { //--------------------------------------------------------------- // Hazard Pointers reclamation schema constants - namespace hzp { + namespace hp { // Max number of threads expected static const size_t c_nMaxThreadCount = 100; // Number of Hazard Pointers per thread static const size_t c_nHazardPointerPerThread = 8; - } // namespace hzp + } // namespace hp } /* namespace gc */ } /* namespace cds */ diff --git a/src/hp_gc.cpp b/src/hp_gc.cpp index 5bfbee4f..eb868c2a 100644 --- a/src/hp_gc.cpp +++ b/src/hp_gc.cpp @@ -17,7 +17,7 @@ #define CDS_HAZARDPTR_STATISTIC( _x ) if ( m_bStatEnabled ) { _x; } namespace cds { namespace gc { - namespace hzp { + namespace hp { /// Max array size of retired pointers static const size_t c_nMaxRetireNodeCount = c_nHazardPointerPerThread * c_nMaxThreadCount * 2; @@ -360,5 +360,5 @@ namespace cds { namespace gc { } - } //namespace hzp + } //namespace hp }} // namespace cds::gc diff --git a/tests/cppunit/test_main.cpp b/tests/cppunit/test_main.cpp index 452c0503..485f95c1 100644 --- a/tests/cppunit/test_main.cpp +++ b/tests/cppunit/test_main.cpp @@ -51,7 +51,7 @@ #endif -std::ostream& operator << (std::ostream& s, const cds::gc::hzp::GarbageCollector::InternalState& stat) +std::ostream& operator << (std::ostream& s, const cds::gc::hp::GarbageCollector::InternalState& stat) { s << "\nHZP GC internal state:" << "\n\t\tHP record allocated=" << stat.nHPRecAllocated @@ -118,8 +118,8 @@ namespace CppUnitMini { if ( m_bPrintGCState ) { { - cds::gc::hzp::GarbageCollector::InternalState stat; - std::cout << cds::gc::hzp::GarbageCollector::instance().getInternalState( stat ) << std::endl; + cds::gc::hp::GarbageCollector::InternalState stat; + std::cout << cds::gc::hp::GarbageCollector::instance().getInternalState( stat ) << std::endl; } } } @@ -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::hzp::inplace ); + hzpGC.setScanType( cds::gc::hp::inplace ); else if ( strHZPScanStrategy == "classic" ) - hzpGC.setScanType( cds::gc::hzp::classic ); + hzpGC.setScanType( cds::gc::hp::classic ); else { std::cout << "Error value of HZP_scan_strategy in General section of test config\n"; } switch (hzpGC.getScanType()) { - case cds::gc::hzp::inplace: + case cds::gc::hp::inplace: std::cout << "Use in-place scan strategy for Hazard Pointer memory reclamation algorithm\n"; break; - case cds::gc::hzp::classic: + case cds::gc::hp::classic: std::cout << "Use classic scan strategy for Hazard Pointer memory reclamation algorithm\n"; break; default: @@ -388,8 +388,8 @@ int main(int argc, char** argv) } if ( CppUnitMini::TestCase::m_bPrintGCState ) { - cds::gc::hzp::GarbageCollector::InternalState stat; - cds::gc::hzp::GarbageCollector::instance().getInternalState( stat ); + cds::gc::hp::GarbageCollector::InternalState stat; + cds::gc::hp::GarbageCollector::instance().getInternalState( stat ); std::cout << "HP constants:" << "\n\tHP count per thread=" << stat.nHPCount -- 2.34.1