rearrange cds/gc contents
[libcds.git] / cds / gc / hp_impl.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_GC_HP_IMPL_H
4 #define __CDS_GC_HP_IMPL_H
5
6 #include <cds/threading/model.h>
7 #include <cds/details/static_functor.h>
8
9 //@cond
10 namespace cds { namespace gc {
11
12     inline HP::thread_gc::thread_gc(
13         bool    bPersistent
14         )
15         : m_bPersistent( bPersistent )
16     {
17         if ( !threading::Manager::isThreadAttached() )
18             threading::Manager::attachThread();
19     }
20
21     inline HP::thread_gc::~thread_gc()
22     {
23         if ( !m_bPersistent )
24             cds::threading::Manager::detachThread();
25     }
26
27     inline HP::Guard::Guard()
28         : Guard::base_class( cds::threading::getGC<HP>() )
29     {}
30
31     template <size_t COUNT>
32     inline HP::GuardArray<COUNT>::GuardArray()
33         : GuardArray::base_class( cds::threading::getGC<HP>() )
34     {}
35
36     template <typename T>
37     inline void HP::retire( T * p, void (* pFunc)(T *) )
38     {
39         cds::threading::getGC<HP>().retirePtr( p, pFunc );
40     }
41
42     template <class Disposer, typename T>
43     inline void HP::retire( T * p )
44     {
45         cds::threading::getGC<HP>().retirePtr( p, cds::details::static_functor<Disposer, T>::call );
46     }
47
48     inline void HP::scan()
49     {
50         cds::threading::getGC<HP>().scan();
51     }
52
53
54 }} // namespace cds::gc
55 //@endcond
56
57 #endif // #ifndef __CDS_GC_HP_IMPL_H