3 #ifndef __CDS_GC_HP_DETAILS_HP_RETIRED_H
4 #define __CDS_GC_HP_DETAILS_HP_RETIRED_H
6 #include <cds/gc/hp/details/hp_fwd.h>
7 #include <cds/gc/hp/details/hp_type.h>
9 #include <cds/details/bounded_array.h>
12 namespace gc{ namespace hzp { namespace details {
15 typedef cds::gc::details::retired_ptr retired_ptr;
17 /// Array of retired pointers
19 The vector of retired pointer ready to delete.
21 The Hazard Pointer schema is build on thread-static arrays. For each HP-enabled thread the HP manager allocates
22 array of retired pointers. The array belongs to the thread: owner thread writes to the array, other threads
25 class retired_vector {
26 /// Underlying vector implementation
27 typedef cds::details::bounded_array<retired_ptr> retired_vector_impl;
29 retired_vector_impl m_arr ; ///< the array of retired pointers
30 size_t m_nSize ; ///< Current size of \p m_arr
34 typedef retired_vector_impl::iterator iterator;
37 retired_vector( const cds::gc::hzp::GarbageCollector& HzpMgr ) ; // inline
43 The capacity is constant for any thread. It is defined by cds::gc::hzp::GarbageCollector.
45 size_t capacity() const { return m_arr.capacity(); }
47 /// Current vector size (count of retired pointers in the vector)
48 size_t size() const { return m_nSize; }
50 /// Set vector size. Uses internally
51 void size( size_t nSize )
53 assert( nSize <= capacity() );
57 /// Pushes retired pointer to the vector
58 void push( const retired_ptr& p )
60 assert( m_nSize < capacity() );
65 /// Checks if the vector is full (size() == capacity() )
68 return m_nSize >= capacity();
72 iterator begin() { return m_arr.begin(); }
74 iterator end() { return m_arr.begin() + m_nSize ; }
76 /// Clears the vector. After clearing, size() == 0
83 } } } // namespace gc::hzp::details
86 #endif // #ifndef __CDS_GC_HP_DETAILS_HP_RETIRED_H