Merge branch 'check' into dev
[libcds.git] / cds / gc / details / hp.h
index b6d052ed3ff00a2c85266eb163c514a4632474df..fde65fddbdb09148a4d8bb7d69e86d4991521d3a 100644 (file)
 
 //@cond
 namespace cds {
-    /**
-        @page cds_garbage_collectors_comparison GC comparison
-        @ingroup cds_garbage_collector
-
-        <table>
-            <tr>
-                <th>Feature</th>
-                <th>%cds::gc::HP</th>
-                <th>%cds::gc::DHP</th>
-            </tr>
-            <tr>
-                <td>Implementation quality</td>
-                <td>stable</td>
-                <td>stable</td>
-            </tr>
-            <tr>
-                <td>Performance rank (1 - slowest, 5 - fastest)</td>
-                <td>5</td>
-                <td>4</td>
-            </tr>
-            <tr>
-                <td>Max number of guarded (hazard) pointers per thread</td>
-                <td>limited (specifies in GC object ctor)</td>
-                <td>unlimited (dynamically allocated when needed)</td>
-            </tr>
-            <tr>
-                <td>Max number of retired pointers<sup>1</sup></td>
-                <td>bounded</td>
-                <td>bounded</td>
-           </tr>
-            <tr>
-                <td>Array of retired pointers</td>
-                <td>preallocated for each thread, limited in size</td>
-                <td>global for the entire process, unlimited (dynamically allocated when needed)</td>
-            </tr>
-            <tr>
-                <td>Support direct pointer to item of lock-free container (useful for iterators)</td>
-                <td>not supported</td>
-                <td>not supported</td>
-            </tr>
-        </table>
-
-        <sup>1</sup>Unbounded count of retired pointer means a possibility of memory exhaustion.
-    */
-
     /// Different safe memory reclamation schemas (garbage collectors)
     /** @ingroup cds_garbage_collector
 
@@ -125,10 +80,10 @@ namespace cds {
 
             public:
                 /// Iterator
-                typedef    retired_vector_impl::iterator    iterator;
+                typedef retired_vector_impl::iterator  iterator;
 
                 /// Constructor
-                retired_vector( const cds::gc::hp::GarbageCollector& HzpMgr ) CDS_NOEXCEPT; // inline
+                retired_vector( const cds::gc::hp::GarbageCollector& HzpMgr ); // inline
                 ~retired_vector()
                 {}
 
@@ -155,7 +110,7 @@ namespace cds {
                 }
 
                 /// Pushes retired pointer to the vector
-                void push( const retired_ptr& p )
+                void push( retired_ptr const& p )
                 {
                     assert( m_nSize < capacity() );
                     m_arr[ m_nSize ] = p;
@@ -283,9 +238,9 @@ namespace cds {
             /// Internal list of cds::gc::hp::details::hp_record
             struct hplist_node : public details::hp_record
             {
-                hplist_node *                       m_pNextNode ; ///< next hazard ptr record in list
-                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)
+                hplist_node *                    m_pNextNode; ///< next hazard ptr record in list
+                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)
 
                 hplist_node( const GarbageCollector& HzpMgr )
                     : hp_record( HzpMgr ),
@@ -658,7 +613,7 @@ namespace cds {
         */
         class guard
         {
-            details::hp_guard&   m_hp    ; ///< Hazard pointer guarded
+            details::hp_guard&  m_hp    ; ///< Hazard pointer guarded
             ThreadGC&           m_gc    ; ///< Thread GC
 
         public:
@@ -749,8 +704,25 @@ namespace cds {
 }}  // namespace cds::gc
 //@endcond
 
+//@cond
 // Inlines
-#include <cds/gc/details/hp_inline.h>
+namespace cds {
+    namespace gc { namespace hp { namespace details {
+
+        inline retired_vector::retired_vector( const cds::gc::hp::GarbageCollector& HzpMgr )
+            : m_arr( HzpMgr.getMaxRetiredPtrCount() ),
+            m_nSize(0)
+        {}
+
+        inline hp_record::hp_record( const cds::gc::hp::GarbageCollector& HzpMgr )
+            : m_hzp( HzpMgr.getHazardPointerCount() ),
+            m_arrRetired( HzpMgr )
+        {}
+
+    }}} // namespace gc::hp::details
+} // namespace cds
+//@endcond
+
 
 #if CDS_COMPILER == CDS_COMPILER_MSVC
 #   pragma warning(pop)