diff --git a/cds/gc/dhp.h b/cds/gc/dhp.h index c9df3e58e..d8453e17e 100644 --- a/cds/gc/dhp.h +++ b/cds/gc/dhp.h @@ -310,7 +310,7 @@ namespace cds { namespace gc { } // no free block - // smr::scan() extend retired_array if needed + // basic_smr::scan() extend retired_array if needed return false; } @@ -325,7 +325,7 @@ namespace cds { namespace gc { return ret; } - private: // called by smr + private: // called by basic_smr void init() { if ( list_head_ == nullptr ) { @@ -479,7 +479,7 @@ namespace cds { namespace gc { struct thread_record; public: - /// Returns the instance of Hazard Pointer \ref smr + /// Returns the instance of Hazard Pointer \ref basic_smr static smr& instance() { # ifdef CDS_DISABLE_SMR_EXCEPTION @@ -517,7 +517,7 @@ namespace cds { namespace gc { construct( nInitialHazardPtrCount ); } - /// Destroys global instance of \ref smr + /// Destroys global instance of \ref basic_smr /** The parameter \p bDetachAll should be used carefully: if its value is \p true, then the object destroyed automatically detaches all attached threads. This feature diff --git a/cds/gc/hp.h b/cds/gc/hp.h index c03cbe7fc..0d5b942c4 100644 --- a/cds/gc/hp.h +++ b/cds/gc/hp.h @@ -347,20 +347,20 @@ namespace cds { namespace gc { }; //@endcond - /// \p smr::scan() strategy + /// \p basic_smr::scan() strategy enum scan_type { - classic, ///< classic scan as described in Michael's works (see smr::classic_scan()) - inplace ///< inplace scan without allocation (see smr::inplace_scan()) + classic, ///< classic scan as described in Michael's works (see basic_smr::classic_scan()) + inplace ///< inplace scan without allocation (see basic_smr::inplace_scan()) }; //@cond /// Hazard Pointer SMR (Safe Memory Reclamation) - class smr { + class basic_smr { struct thread_record; public: - /// Returns the instance of Hazard Pointer \ref smr - static smr &instance() { + /// Returns the instance of Hazard Pointer \ref basic_smr + static basic_smr &instance() { # ifdef CDS_DISABLE_SMR_EXCEPTION assert( instance_ != nullptr ); # else @@ -401,7 +401,7 @@ namespace cds { namespace gc { construct(nHazardPtrCount, nMaxThreadCount, nMaxRetiredPtrCount, nScanType); } - /// Destroys global instance of \ref smr + /// Destroys global instance of \ref basic_smr /** The parameter \p bDetachAll should be used carefully: if its value is \p true, then the object destroyed automatically detaches all attached threads. This feature @@ -511,14 +511,14 @@ namespace cds { namespace gc { CDS_EXPORT_API void help_scan(thread_data *pThis); private: - CDS_EXPORT_API smr( + CDS_EXPORT_API basic_smr( size_t nHazardPtrCount, ///< Hazard pointer count per thread size_t nMaxThreadCount, ///< Max count of simultaneous working thread in your application size_t nMaxRetiredPtrCount, ///< Capacity of the array of retired objects for the thread scan_type nScanType ///< Scan type (see \ref scan_type enum) ); - CDS_EXPORT_API ~smr(); + CDS_EXPORT_API ~basic_smr(); CDS_EXPORT_API void detach_all_thread(); @@ -567,7 +567,7 @@ namespace cds { namespace gc { CDS_EXPORT_API void free_thread_data(thread_record *pRec, bool callHelpScan); private: - static CDS_EXPORT_API smr *instance_; + static CDS_EXPORT_API basic_smr *instance_; atomics::atomic thread_list_; ///< Head of thread list @@ -575,7 +575,7 @@ namespace cds { namespace gc { size_t const max_thread_count_; ///< max count of thread size_t const max_retired_ptr_count_; ///< max count of retired ptr per thread scan_type const scan_type_; ///< scan type (see \ref scan_type enum) - void ( smr::*scan_func_ )(thread_data *pRec); + void ( basic_smr::*scan_func_ )(thread_data *pRec); }; //@endcond @@ -583,7 +583,7 @@ namespace cds { namespace gc { //@cond // for backward compatibility - typedef details::smr smr; + typedef details::basic_smr smr; typedef smr GarbageCollector; //@endcond } // namespace hp @@ -1467,7 +1467,7 @@ namespace cds { namespace gc { } // namespace cds::gc::details typedef details::HP HP; - typedef hp::details::smr smr; + typedef hp::details::basic_smr smr; }} // namespace cds::gc #endif // #ifndef CDSLIB_GC_HP_SMR_H diff --git a/src/hp.cpp b/src/hp.cpp index 33a93ab18..94d0c50db 100644 --- a/src/hp.cpp +++ b/src/hp.cpp @@ -117,16 +117,16 @@ namespace cds { namespace gc { namespace hp { namespace details { stat s_postmortem_stat; } // namespace - /*static*/ CDS_EXPORT_API smr* smr::instance_ = nullptr; + /*static*/ CDS_EXPORT_API basic_smr* basic_smr::instance_ = nullptr; thread_local thread_data* tls_ = nullptr; - /*static*/ CDS_EXPORT_API thread_data* smr::tls() + /*static*/ CDS_EXPORT_API thread_data* basic_smr::tls() { assert( tls_ != nullptr ); return tls_; } - struct smr::thread_record: thread_data + struct basic_smr::thread_record: thread_data { // next hazard ptr record in list thread_record* next_ = nullptr; @@ -140,7 +140,7 @@ namespace cds { namespace gc { namespace hp { namespace details { {} }; - /*static*/ CDS_EXPORT_API void smr::set_memory_allocator( + /*static*/ CDS_EXPORT_API void basic_smr::set_memory_allocator( void* ( *alloc_func )( size_t size ), void( *free_func )( void * p ) ) @@ -153,36 +153,36 @@ namespace cds { namespace gc { namespace hp { namespace details { } - /*static*/ CDS_EXPORT_API void smr::construct( size_t nHazardPtrCount, size_t nMaxThreadCount, size_t nMaxRetiredPtrCount, scan_type nScanType ) + /*static*/ CDS_EXPORT_API void basic_smr::construct(size_t nHazardPtrCount, size_t nMaxThreadCount, size_t nMaxRetiredPtrCount, scan_type nScanType ) { if ( !instance_ ) { - instance_ = new( s_alloc_memory(sizeof(smr))) smr( nHazardPtrCount, nMaxThreadCount, nMaxRetiredPtrCount, nScanType ); + instance_ = new( s_alloc_memory(sizeof(basic_smr))) basic_smr(nHazardPtrCount, nMaxThreadCount, nMaxRetiredPtrCount, nScanType ); } } - /*static*/ CDS_EXPORT_API void smr::destruct( bool bDetachAll ) + /*static*/ CDS_EXPORT_API void basic_smr::destruct(bool bDetachAll ) { if ( instance_ ) { if ( bDetachAll ) instance_->detach_all_thread(); - instance_->~smr(); + instance_->~basic_smr(); s_free_memory( instance_ ); instance_ = nullptr; } } - CDS_EXPORT_API smr::smr( size_t nHazardPtrCount, size_t nMaxThreadCount, size_t nMaxRetiredPtrCount, scan_type nScanType ) + CDS_EXPORT_API basic_smr::basic_smr(size_t nHazardPtrCount, size_t nMaxThreadCount, size_t nMaxRetiredPtrCount, scan_type nScanType ) : hazard_ptr_count_( nHazardPtrCount == 0 ? defaults::c_nHazardPointerPerThread : nHazardPtrCount ) , max_thread_count_( nMaxThreadCount == 0 ? defaults::c_nMaxThreadCount : nMaxThreadCount ) , max_retired_ptr_count_( calc_retired_size( nMaxRetiredPtrCount, hazard_ptr_count_, max_thread_count_ )) , scan_type_( nScanType ) - , scan_func_( nScanType == classic ? &smr::classic_scan : &smr::inplace_scan ) + , scan_func_( nScanType == classic ? &basic_smr::classic_scan : &basic_smr::inplace_scan ) { thread_list_.store( nullptr, atomics::memory_order_release ); } - CDS_EXPORT_API smr::~smr() + CDS_EXPORT_API basic_smr::~basic_smr() { CDS_DEBUG_ONLY( const cds::OS::ThreadId nullThreadId = cds::OS::c_NullThreadId; ) CDS_DEBUG_ONLY( const cds::OS::ThreadId mainThreadId = cds::OS::get_current_thread_id();) @@ -212,7 +212,7 @@ namespace cds { namespace gc { namespace hp { namespace details { } - CDS_EXPORT_API smr::thread_record* smr::create_thread_data() + CDS_EXPORT_API basic_smr::thread_record* basic_smr::create_thread_data() { size_t const guard_array_size = thread_hp_storage::calc_array_size( get_hazard_ptr_count()); size_t const retired_array_size = retired_array::calc_array_size( get_max_retired_ptr_count()); @@ -248,7 +248,7 @@ namespace cds { namespace gc { namespace hp { namespace details { ); } - /*static*/ CDS_EXPORT_API void smr::destroy_thread_data( thread_record* pRec ) + /*static*/ CDS_EXPORT_API void basic_smr::destroy_thread_data(thread_record* pRec ) { // all retired pointers must be freed assert( pRec->retired_.size() == 0 ); @@ -258,7 +258,7 @@ namespace cds { namespace gc { namespace hp { namespace details { } - CDS_EXPORT_API smr::thread_record* smr::alloc_thread_data() + CDS_EXPORT_API basic_smr::thread_record* basic_smr::alloc_thread_data() { thread_record * hprec; const cds::OS::ThreadId nullThreadId = cds::OS::c_NullThreadId; @@ -286,7 +286,7 @@ namespace cds { namespace gc { namespace hp { namespace details { return hprec; } - CDS_EXPORT_API void smr::free_thread_data( smr::thread_record* pRec, bool callHelpScan ) + CDS_EXPORT_API void basic_smr::free_thread_data(basic_smr::thread_record* pRec, bool callHelpScan ) { assert( pRec != nullptr ); @@ -297,7 +297,7 @@ namespace cds { namespace gc { namespace hp { namespace details { pRec->thread_id_.store( cds::OS::c_NullThreadId, atomics::memory_order_release ); } - CDS_EXPORT_API void smr::detach_all_thread() + CDS_EXPORT_API void basic_smr::detach_all_thread() { thread_record * pNext = nullptr; const cds::OS::ThreadId nullThreadId = cds::OS::c_NullThreadId; @@ -310,13 +310,13 @@ namespace cds { namespace gc { namespace hp { namespace details { } } - /*static*/ CDS_EXPORT_API void smr::attach_thread() + /*static*/ CDS_EXPORT_API void basic_smr::attach_thread() { if ( !tls_ ) tls_ = instance().alloc_thread_data(); } - /*static*/ CDS_EXPORT_API void smr::detach_thread() + /*static*/ CDS_EXPORT_API void basic_smr::detach_thread() { thread_data* rec = tls_; if ( rec ) { @@ -326,7 +326,7 @@ namespace cds { namespace gc { namespace hp { namespace details { } - CDS_EXPORT_API void smr::inplace_scan( thread_data* pThreadRec ) + CDS_EXPORT_API void basic_smr::inplace_scan(thread_data* pThreadRec ) { thread_record* pRec = static_cast( pThreadRec ); @@ -415,7 +415,7 @@ namespace cds { namespace gc { namespace hp { namespace details { } // cppcheck-suppress functionConst - CDS_EXPORT_API void smr::classic_scan( thread_data* pThreadRec ) + CDS_EXPORT_API void basic_smr::classic_scan(thread_data* pThreadRec ) { thread_record* pRec = static_cast( pThreadRec ); @@ -469,7 +469,7 @@ namespace cds { namespace gc { namespace hp { namespace details { } } - CDS_EXPORT_API void smr::help_scan( thread_data* pThis ) + CDS_EXPORT_API void basic_smr::help_scan(thread_data* pThis ) { assert( static_cast( pThis )->thread_id_.load( atomics::memory_order_relaxed ) == cds::OS::get_current_thread_id()); @@ -520,7 +520,7 @@ namespace cds { namespace gc { namespace hp { namespace details { } } - CDS_EXPORT_API void smr::statistics( stat& st ) + CDS_EXPORT_API void basic_smr::statistics(stat& st ) { st.clear(); # ifdef CDS_ENABLE_HPSTAT