Rename class cds::gc::PTB to cds::gc::DHP
[libcds.git] / cds / threading / model.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_THREADING_MODEL_H
4 #define __CDS_THREADING_MODEL_H
5
6 #include <cds/threading/details/_common.h>
7 #include <cds/user_setup/threading.h>
8 #include <cds/threading/details/auto_detect.h>
9
10 namespace cds { namespace threading {
11
12     /// Returns thread specific data of \p GC garbage collector
13     template <class GC> typename GC::thread_gc_impl&  getGC();
14
15     /// Returns RCU thread specific data (thread GC) for current thread
16     /**
17         Template argument \p RCUtag is one of \ref cds_urcu_tags "RCU tags"
18     */
19     template <typename RCUtag> cds::urcu::details::thread_data<RCUtag> * getRCU();
20
21     /// Get cds::gc::HP thread GC implementation for current thread
22     /**
23         The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution
24         or if you did not use cds::gc::HP.
25         To initialize cds::gc::HP GC you must constuct cds::gc::HP object in the beginning of your application,
26         see \ref cds_how_to_use "How to use libcds"
27     */
28     template <>
29     inline cds::gc::HP::thread_gc_impl&   getGC<cds::gc::HP>()
30     {
31         return Manager::getHZPGC();
32     }
33
34     /// Get cds::gc::DHP thread GC implementation for current thread
35     /**
36         The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution
37         or if you did not use cds::gc::DHP.
38         To initialize cds::gc::DHP GC you must constuct cds::gc::DHP object in the beginning of your application,
39         see \ref cds_how_to_use "How to use libcds"
40     */
41     template <>
42     inline cds::gc::DHP::thread_gc_impl&   getGC<cds::gc::DHP>()
43     {
44         return Manager::getDHPGC();
45     }
46
47     //@cond
48     template<>
49     inline cds::urcu::details::thread_data<cds::urcu::general_instant_tag> * getRCU<cds::urcu::general_instant_tag>()
50     {
51         return Manager::thread_data()->m_pGPIRCU;
52     }
53     template<>
54     inline cds::urcu::details::thread_data<cds::urcu::general_buffered_tag> * getRCU<cds::urcu::general_buffered_tag>()
55     {
56         return Manager::thread_data()->m_pGPBRCU;
57     }
58     template<>
59     inline cds::urcu::details::thread_data<cds::urcu::general_threaded_tag> * getRCU<cds::urcu::general_threaded_tag>()
60     {
61         return Manager::thread_data()->m_pGPTRCU;
62     }
63 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
64     template<>
65     inline cds::urcu::details::thread_data<cds::urcu::signal_buffered_tag> * getRCU<cds::urcu::signal_buffered_tag>()
66     {
67         ThreadData * p = Manager::thread_data();
68         return p ? p->m_pSHBRCU : nullptr;
69     }
70     template<>
71     inline cds::urcu::details::thread_data<cds::urcu::signal_threaded_tag> * getRCU<cds::urcu::signal_threaded_tag>()
72     {
73         ThreadData * p = Manager::thread_data();
74         return p ? p->m_pSHTRCU : nullptr;
75     }
76 #endif
77
78     static inline cds::algo::elimination::record& elimination_record()
79     {
80         return Manager::thread_data()->m_EliminationRec;
81     }
82     //@endcond
83
84 }} // namespace cds::threading
85
86 #endif // #ifndef __CDS_THREADING_MODEL_H