issue#11: cds: changed __CDS_ guard prefix to CDSLIB_ for all .h files
[libcds.git] / cds / gc / impl / dhp_impl.h
1 //$$CDS-header$$
2
3 #ifndef CDSLIB_GC_IMPL_DHP_IMPL_H
4 #define CDSLIB_GC_IMPL_DHP_IMPL_H
5
6 #include <cds/threading/model.h>
7
8 //@cond
9 namespace cds { namespace gc {
10
11     namespace dhp {
12
13         inline Guard::Guard()
14         {
15             cds::threading::getGC<DHP>().allocGuard( *this );
16         }
17
18         inline Guard::~Guard()
19         {
20             cds::threading::getGC<DHP>().freeGuard( *this );
21         }
22
23         template <size_t Count>
24         inline GuardArray<Count>::GuardArray()
25         {
26             cds::threading::getGC<DHP>().allocGuard( *this );
27         }
28
29         template <size_t Count>
30         inline GuardArray<Count>::~GuardArray()
31         {
32             cds::threading::getGC<DHP>().freeGuard( *this );
33         }
34     } // namespace dhp
35
36
37     inline DHP::thread_gc::thread_gc(
38         bool    bPersistent
39         )
40         : m_bPersistent( bPersistent )
41     {
42         if ( !cds::threading::Manager::isThreadAttached() )
43             cds::threading::Manager::attachThread();
44     }
45
46     inline DHP::thread_gc::~thread_gc()
47     {
48         if ( !m_bPersistent )
49             cds::threading::Manager::detachThread();
50     }
51
52     inline /*static*/ void DHP::thread_gc::alloc_guard( cds::gc::dhp::details::guard& g )
53     {
54         return cds::threading::getGC<DHP>().allocGuard(g);
55     }
56     inline /*static*/ void DHP::thread_gc::free_guard( cds::gc::dhp::details::guard& g )
57     {
58         cds::threading::getGC<DHP>().freeGuard(g);
59     }
60
61     inline void DHP::scan()
62     {
63         cds::threading::getGC<DHP>().scan();
64     }
65
66 }} // namespace cds::gc
67 //@endcond
68
69 #endif // #ifndef CDSLIB_GC_IMPL_DHP_IMPL_H