Hazard Pointer docfix
authorkhizmax <libcds.dev@gmail.com>
Sat, 15 Nov 2014 15:22:48 +0000 (18:22 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sat, 15 Nov 2014 15:22:48 +0000 (18:22 +0300)
cds/gc/details/dhp.h
cds/gc/details/hp.h
cds/gc/details/hp_alloc.h
cds/gc/details/hp_inline.h
cds/gc/details/hp_type.h
cds/gc/impl/dhp_decl.h
cds/gc/impl/dhp_impl.h
cds/gc/impl/hp_decl.h
cds/gc/impl/hp_impl.h

index 8e117c7a0c3ef5ce16acbc987599318225713ea8..70e70c5d070cf0fadc6f8764f2a9ab8c4a76e94d 100644 (file)
@@ -15,6 +15,7 @@
 #   pragma warning(disable:4251)    // C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
 #endif
 
+//@cond
 namespace cds { namespace gc {
 
     /// Dynamic Hazard Pointer reclamation schema
@@ -72,7 +73,6 @@ namespace cds { namespace gc {
 
                 guard_data *             pThreadNext ;   ///< next item of thread's local list of guards
 
-                //@cond
                 guard_data() CDS_NOEXCEPT
                     : pPost( nullptr )
                     , pGlobalNext( nullptr )
@@ -84,7 +84,6 @@ namespace cds { namespace gc {
                 {
                     pPost.store( nullptr, atomics::memory_order_relaxed );
                 }
-                //@endcond
 
                 /// Checks if the guard is free, that is, it does not contain any pointer guarded
                 bool isFree() const CDS_NOEXCEPT
@@ -250,7 +249,6 @@ namespace cds { namespace gc {
                 atomics::atomic<size_t>              m_nItemCount;   ///< buffer's item count
 
             public:
-                //@cond
                 CDS_CONSTEXPR retired_ptr_buffer() CDS_NOEXCEPT
                     : m_pHead( nullptr )
                     , m_nItemCount(0)
@@ -260,7 +258,6 @@ namespace cds { namespace gc {
                 {
                     assert( m_pHead.load( atomics::memory_order_relaxed ) == nullptr );
                 }
-                //@endcond
 
                 /// Pushes new node into the buffer. Returns current buffer size
                 size_t push( retired_ptr_node& node ) CDS_NOEXCEPT
@@ -331,7 +328,6 @@ namespace cds { namespace gc {
                 cds::details::Allocator< block, Alloc > m_BlockAllocator    ;   ///< block allocator
 
             private:
-                //@cond
                 void allocNewBlock()
                 {
                     // allocate new block
@@ -372,10 +368,8 @@ namespace cds { namespace gc {
                 {
                     return (m_nCurEpoch.load(atomics::memory_order_acquire) - 1) & (c_nEpochCount - 1);
                 }
-                //@endcond
 
             public:
-                //@cond
                 retired_ptr_pool()
                     : m_pBlockListHead( nullptr )
                     , m_nCurEpoch(0)
@@ -402,8 +396,6 @@ namespace cds { namespace gc {
                     m_nCurEpoch.fetch_add( 1, atomics::memory_order_acq_rel );
                 }
 
-                //@endcond
-
                 /// Allocates new retired pointer
                 retired_ptr_node&  alloc()
                 {
@@ -503,13 +495,11 @@ namespace cds { namespace gc {
                     return p;
                 }
 
-                //@cond
                 std::nullptr_t operator=(std::nullptr_t) CDS_NOEXCEPT
                 {
                     clear();
                     return nullptr;
                 }
-                //@endcond
 
             public: // for ThreadGC.
                 /*
@@ -547,10 +537,8 @@ namespace cds { namespace gc {
         */
         class Guard: public details::guard
         {
-            //@cond
             typedef details::guard    base_class;
             friend class ThreadGC;
-            //@endcond
 
             ThreadGC&    m_gc    ;    ///< ThreadGC object of current thread
         public:
@@ -573,12 +561,10 @@ namespace cds { namespace gc {
                 return base_class::operator =<T>( p );
             }
 
-            //@cond
             std::nullptr_t operator=(std::nullptr_t) CDS_NOEXCEPT
             {
                 return base_class::operator =(nullptr);
             }
-            //@endcond
         };
 
         /// Array of guards
@@ -666,7 +652,6 @@ namespace cds { namespace gc {
         class CDS_EXPORT_API GarbageCollector
         {
         private:
-            //@cond
             friend class ThreadGC;
 
             /// Internal GC statistics
@@ -680,7 +665,6 @@ namespace cds { namespace gc {
                     , m_nFreeGuardCount(0)
                 {}
             };
-            //@endcond
 
         public:
             /// Exception "No GarbageCollector object is created"
@@ -692,7 +676,6 @@ namespace cds { namespace gc {
                 size_t m_nGuardCount       ;   ///< Total guard count
                 size_t m_nFreeGuardCount   ;   ///< Count of free guard
 
-                //@cond
                 InternalState()
                     : m_nGuardCount(0)
                     , m_nFreeGuardCount(0)
@@ -705,7 +688,6 @@ namespace cds { namespace gc {
 
                     return *this;
                 }
-                //@endcond
             };
 
         private:
@@ -844,10 +826,8 @@ namespace cds { namespace gc {
             }
 
         private:
-            //@cond none
             GarbageCollector( size_t nLiberateThreshold, size_t nInitialThreadGuardCount );
             ~GarbageCollector();
-            //@endcond
         };
 
         /// Thread GC
@@ -975,13 +955,10 @@ namespace cds { namespace gc {
                 m_gc.retirePtr( p, pFunc );
             }
 
-            //@cond
             void scan()
             {
                 m_gc.scan();
             }
-            //@endcond
-
         };
 
         //////////////////////////////////////////////////////////
@@ -1011,6 +988,7 @@ namespace cds { namespace gc {
 
     }   // namespace dhp
 }}  // namespace cds::gc
+//@endcond
 
 #if CDS_COMPILER == CDS_COMPILER_MSVC
 #   pragma warning(pop)
index 0e9f0c0d9a3d8dcf9ff748970a8024cd3e21e146..88b56fa786e11f41bda4a1d5cb04419ec1a8ce54 100644 (file)
@@ -27,6 +27,7 @@
         2010.01.27  khizmax Introducing memory order constraint
 */
 
+//@cond
 namespace cds {
     /**
         @page cds_garbage_collectors_comparison GC comparison
@@ -286,7 +287,6 @@ namespace cds {
                 atomics::atomic<OS::ThreadId>    m_idOwner   ; ///< Owner thread id; 0 - the record is free (not owned)
                 atomics::atomic<bool>            m_bFree     ; ///< true if record if free (not owned)
 
-                //@cond
                 hplist_node( const GarbageCollector& HzpMgr )
                     : hp_record( HzpMgr ),
                     m_pNextNode( nullptr ),
@@ -299,7 +299,6 @@ namespace cds {
                     assert( m_idOwner.load( atomics::memory_order_relaxed ) == OS::c_NullThreadId );
                     assert( m_bFree.load(atomics::memory_order_relaxed) );
                 }
-                //@endcond
             };
 
             atomics::atomic<hplist_node *>   m_pListHead  ;  ///< Head of GC list
@@ -342,9 +341,7 @@ namespace cds {
             */
             void                DeletePtr( details::retired_ptr& p );
 
-            //@cond
             void detachAllThread();
-            //@endcond
 
         public:
             /// Creates GarbageCollector singleton
@@ -646,13 +643,11 @@ namespace cds {
                 }
             }
 
-            //@cond
             void scan()
             {
                 m_HzpManager.Scan( m_pHzpRec );
                 m_HzpManager.HelpScan( m_pHzpRec );
             }
-            //@endcond
         };
 
         /// Auto hp_guard.
@@ -663,13 +658,12 @@ namespace cds {
         */
         class guard
         {
-            //@cond
             details::hp_guard&   m_hp    ; ///< Hazard pointer guarded
             ThreadGC&           m_gc    ; ///< Thread GC
-            //@endcond
 
         public:
             typedef details::hp_guard::hazard_ptr hazard_ptr ;  ///< Hazard pointer type
+
         public:
             /// Allocates HP guard from \p gc
             guard( ThreadGC& gc )
@@ -705,7 +699,6 @@ namespace cds {
                 return m_hp = p;
             }
 
-            //@cond
             std::nullptr_t operator =(std::nullptr_t)
             {
                 return m_hp = nullptr;
@@ -715,7 +708,6 @@ namespace cds {
             {
                 return m_hp;
             }
-            //@endcond
         };
 
         /// Auto-managed array of hazard pointers
@@ -755,6 +747,7 @@ namespace cds {
 
     }   // namespace hp
 }}  // namespace cds::gc
+//@endcond
 
 // Inlines
 #include <cds/gc/details/hp_inline.h>
index e057e1baf7775d0c533c39cb1f2c077325dd1d9f..de409bcfd426f9dd86548e08f749c1e7360c94dc 100644 (file)
@@ -27,14 +27,10 @@ namespace cds {
         public:
             typedef hazard_pointer   hazard_ptr;    ///< Hazard pointer type
         private:
-            //@cond
             typedef atomics::atomic<hazard_ptr>  base_class;
-            //@endcond
 
         protected:
-            //@cond
             template <class Allocator> friend class hp_allocator;
-            //@endcond
 
         public:
             hp_guard() CDS_NOEXCEPT
@@ -55,13 +51,11 @@ namespace cds {
                 return p;
             }
 
-            //@cond
             std::nullptr_t operator=(std::nullptr_t) CDS_NOEXCEPT
             {
                 clear();
                 return nullptr;
             }
-            //@endcond
 
             /// Returns current value of hazard pointer
             /**
@@ -126,10 +120,8 @@ namespace cds {
             static CDS_CONSTEXPR const size_t c_nCapacity = Count ;   ///< Capacity of the array
 
         private:
-            //@cond
             atomic_hazard_ptr *     m_arr               ;   ///< Hazard pointer array of size = \p Count
             template <class Allocator> friend class hp_allocator;
-            //@endcond
 
         public:
             /// Constructs uninitialized array.
@@ -197,15 +189,12 @@ namespace cds {
             typedef Allocator       allocator_type;     ///< allocator type
 
         private:
-            //@cond
             typedef cds::details::Allocator< atomic_hazard_ptr, allocator_type > allocator_impl;
 
             atomic_hazard_ptr * m_arrHazardPtr  ;   ///< Array of hazard pointers
             size_t              m_nTop          ;   ///< The top of stack
             const size_t        m_nCapacity     ;   ///< Array capacity
 
-            //@endcond
-
         public:
             /// Default ctor
             explicit hp_allocator(
@@ -298,7 +287,6 @@ namespace cds {
             }
 
         private:
-            //@cond
             void make_free() CDS_NOEXCEPT
             {
                 for ( size_t i = 0; i < capacity(); ++i )
@@ -310,7 +298,6 @@ namespace cds {
             {
                 return allocator_impl().NewArray( nCapacity );
             }
-            //@endcond
         };
 
     }}} // namespace gc::hp::details
index 86bc997c9ad885d4c0a3049648d7cfce79cda79d..e4e22a8dcaa506d39b09cde6b141a6cf622d79f0 100644 (file)
@@ -3,6 +3,7 @@
 #ifndef __CDS_GC_DETAILS_HP_INLINE_H
 #define __CDS_GC_DETAILS_HP_INLINE_H
 
+//@cond
 namespace cds {
     namespace gc{ namespace hp { namespace details {
 
@@ -19,8 +20,8 @@ namespace cds {
             m_arrRetired( HzpMgr )
         {}
 
-    } } }    // namespace gc::hp::details
+    }}}    // namespace gc::hp::details
 }    // namespace cds
-
+//@endcond
 
 #endif // #ifndef __CDS_GC_DETAILS_HP_INLINE_H
index 216712163fe6563192f4357c3e722e9747efc181..27d2dd0d28951866b89d06c82778f17b48a524bf 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <cds/gc/details/retired_ptr.h> // free_retired_ptr_func
 
+//@cond
 namespace cds {
     namespace gc {
         namespace hp {
@@ -17,6 +18,7 @@ namespace cds {
         }
     }
 }
+//@endcond
 
 #endif // #ifndef __CDS_GC_DETAILS_HP_TYPE_H
 
index 9c26fd8709719de6bde4b6a57468f1e28b99f639..0f31ce3140e200389f705c5bde1243b1b725dac0 100644 (file)
@@ -1,7 +1,7 @@
 //$$CDS-header$$
 
-#ifndef __CDS_GC_DHP_DHP_DECL_H
-#define __CDS_GC_DHP_DHP_DECL_H
+#ifndef __CDS_GC_IMPL_DHP_DECL_H
+#define __CDS_GC_IMPL_DHP_DECL_H
 
 #include <cds/gc/details/dhp.h>
 #include <cds/details/marked_ptr.h>
@@ -447,4 +447,4 @@ namespace cds { namespace gc {
 
 }} // namespace cds::gc
 
-#endif // #ifndef __CDS_GC_DHP_DHP_DECL_H
+#endif // #ifndef __CDS_GC_IMPL_DHP_DECL_H
index 10b15f8e03d69947366dd188406c17178cb7f177..834330b8e5920e93b600ceafb6863c50c6d0a167 100644 (file)
@@ -1,7 +1,7 @@
 //$$CDS-header$$
 
-#ifndef __CDS_GC_DHP_DHP_IMPL_H
-#define __CDS_GC_DHP_DHP_IMPL_H
+#ifndef __CDS_GC_IMPL_DHP_IMPL_H
+#define __CDS_GC_IMPL_DHP_IMPL_H
 
 #include <cds/threading/model.h>
 
@@ -40,4 +40,4 @@ namespace cds { namespace gc {
 }} // namespace cds::gc
 //@endcond
 
-#endif // #ifndef __CDS_GC_DHP_DHP_IMPL_H
+#endif // #ifndef __CDS_GC_IMPL_DHP_IMPL_H
index 2beb88af61ba307007209e14f9f3eac7675677b2..2524ddb91e6087d5f6149da6af4a11001510d17a 100644 (file)
@@ -1,7 +1,7 @@
 //$$CDS-header$$
 
-#ifndef __CDS_GC_HP_HP_DECL_H
-#define __CDS_GC_HP_HP_DECL_H
+#ifndef __CDS_GC_IMPL_HP_DECL_H
+#define __CDS_GC_IMPL_HP_DECL_H
 
 #include <stdexcept>    // overflow_error
 #include <cds/gc/details/hp.h>
@@ -360,6 +360,11 @@ namespace cds { namespace gc {
         };
 
     public:
+        /// \p scan() type
+        enum class scan_type {
+            classic = hp::classic,    ///< classic scan as described in Michael's papers
+            inplace = hp::inplace     ///< inplace scan without allocation
+        };
         /// Initializes hp::GarbageCollector singleton
         /**
             The constructor initializes GC singleton with passed parameters.
@@ -378,14 +383,14 @@ 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
-            hp::scan_type nScanType = hp::inplace   ///< Scan type (see \ref hp::scan_type enum)
+            scan_type nScanType = scan_type::inplace   ///< Scan type (see \p scan_type enum)
         )
         {
             hp::GarbageCollector::Construct(
                 nHazardPtrCount,
                 nMaxThreadCount,
                 nMaxRetiredPtrCount,
-                nScanType
+                static_cast<hp::scan_type>(nScanType)
             );
         }
 
@@ -494,17 +499,17 @@ namespace cds { namespace gc {
         static void retire( T * p ) ;   // inline in hp_impl.h
 
         /// Get current scan strategy
-        hp::scan_type getScanType() const
+        scan_type getScanType() const
         {
-            return hp::GarbageCollector::instance().getScanType();
+            return static_cast<scan_type>( hp::GarbageCollector::instance().getScanType());
         }
 
         /// Set current scan strategy
         void setScanType(
-            hp::scan_type nScanType     ///< new scan strategy
+            scan_type nScanType     ///< new scan strategy
         )
         {
-            hp::GarbageCollector::instance().setScanType( nScanType );
+            hp::GarbageCollector::instance().setScanType( static_cast<hp::scan_type>(nScanType) );
         }
 
         /// Checks if Hazard Pointer GC is constructed and may be used
@@ -513,7 +518,6 @@ namespace cds { namespace gc {
             return hp::GarbageCollector::isUsed();
         }
 
-
         /// Forced GC cycle call for current thread
         /**
             Usually, this function should not be called directly.
@@ -528,4 +532,4 @@ namespace cds { namespace gc {
     };
 }}  // namespace cds::gc
 
-#endif  // #ifndef __CDS_GC_HP_HP_DECL_H
+#endif  // #ifndef __CDS_GC_IMPL_HP_DECL_H
index 8d046e30763698e167b97ddc9a14eae5c5b284c2..ccabd381d66ceeae3a2d9ad4f9b6784cf7449cc8 100644 (file)
@@ -1,7 +1,7 @@
 //$$CDS-header$$
 
-#ifndef __CDS_GC_HP_HP_IMPL_H
-#define __CDS_GC_HP_HP_IMPL_H
+#ifndef __CDS_GC_IMPL_HP_IMPL_H
+#define __CDS_GC_IMPL_HP_IMPL_H
 
 #include <cds/threading/model.h>
 #include <cds/details/static_functor.h>
@@ -54,4 +54,4 @@ namespace cds { namespace gc {
 }} // namespace cds::gc
 //@endcond
 
-#endif // #ifndef __CDS_GC_HP_HP_IMPL_H
+#endif // #ifndef __CDS_GC_IMPL_HP_IMPL_H