3 #ifndef CDSLIB_GC_DETAILS_RETIRED_PTR_H
4 #define CDSLIB_GC_DETAILS_RETIRED_PTR_H
6 #include <cds/details/defs.h>
9 namespace cds { namespace gc {
10 /// Common implementation details for any GC
13 /// Pointer to function to free (destruct and deallocate) retired pointer of specific type
14 typedef void (* free_retired_ptr_func )( void * );
18 Pointer to an object that is ready to delete.
22 typedef void * pointer;
25 pointer m_p; ///< retired pointer
28 free_retired_ptr_func m_funcFree; ///< pointer to the destructor function
30 /// Comparison of two retired pointers
31 static bool less( const retired_ptr& p1, const retired_ptr& p2 ) CDS_NOEXCEPT
33 return p1.m_p < p2.m_p;
36 /// Default ctor initializes pointer to \p nullptr
37 retired_ptr() CDS_NOEXCEPT
39 , m_funcFree( nullptr )
43 retired_ptr( pointer p, free_retired_ptr_func func ) CDS_NOEXCEPT
50 retired_ptr( T * p, void (* pFreeFunc)(T *)) CDS_NOEXCEPT
51 : m_p( reinterpret_cast<pointer>(p))
52 , m_funcFree( reinterpret_cast< free_retired_ptr_func >( pFreeFunc ))
55 /// Assignment operator
56 retired_ptr& operator =( retired_ptr const& s) CDS_NOEXCEPT
59 m_funcFree = s.m_funcFree;
63 /// Invokes destructor function for the pointer
70 CDS_STRICT_DO( m_p = nullptr );
71 CDS_STRICT_DO( m_funcFree = nullptr );
75 static inline bool operator <( const retired_ptr& p1, const retired_ptr& p2 ) CDS_NOEXCEPT
77 return retired_ptr::less( p1, p2 );
80 static inline bool operator ==( const retired_ptr& p1, const retired_ptr& p2 ) CDS_NOEXCEPT
82 return p1.m_p == p2.m_p;
85 static inline bool operator !=( const retired_ptr& p1, const retired_ptr& p2 ) CDS_NOEXCEPT
89 } // namespace details
90 }} // namespace cds::gc
93 #endif // #ifndef CDSLIB_GC_DETAILS_RETIRED_PTR_H