3 #ifndef __CDS_THREADING_MODEL_H
4 #define __CDS_THREADING_MODEL_H
6 #include <cds/threading/details/_common.h>
7 #include <cds/user_setup/threading.h>
8 #include <cds/threading/details/auto_detect.h>
10 namespace cds { namespace threading {
12 /// Returns thread specific data of \p GC garbage collector
13 template <class GC> typename GC::thread_gc_impl& getGC();
15 /// Returns RCU thread specific data (thread GC) for current thread
17 Template argument \p RCUtag is one of \ref cds_urcu_tags "RCU tags"
19 template <typename RCUtag> cds::urcu::details::thread_data<RCUtag> * getRCU();
21 /// Get cds::gc::HP thread GC implementation for current thread
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"
29 inline cds::gc::HP::thread_gc_impl& getGC<cds::gc::HP>()
31 return Manager::getHZPGC();
34 /// Get cds::gc::DHP thread GC implementation for current thread
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"
42 inline cds::gc::DHP::thread_gc_impl& getGC<cds::gc::DHP>()
44 return Manager::getDHPGC();
49 inline cds::urcu::details::thread_data<cds::urcu::general_instant_tag> * getRCU<cds::urcu::general_instant_tag>()
51 return Manager::thread_data()->m_pGPIRCU;
54 inline cds::urcu::details::thread_data<cds::urcu::general_buffered_tag> * getRCU<cds::urcu::general_buffered_tag>()
56 return Manager::thread_data()->m_pGPBRCU;
59 inline cds::urcu::details::thread_data<cds::urcu::general_threaded_tag> * getRCU<cds::urcu::general_threaded_tag>()
61 return Manager::thread_data()->m_pGPTRCU;
63 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
65 inline cds::urcu::details::thread_data<cds::urcu::signal_buffered_tag> * getRCU<cds::urcu::signal_buffered_tag>()
67 ThreadData * p = Manager::thread_data();
68 return p ? p->m_pSHBRCU : nullptr;
71 inline cds::urcu::details::thread_data<cds::urcu::signal_threaded_tag> * getRCU<cds::urcu::signal_threaded_tag>()
73 ThreadData * p = Manager::thread_data();
74 return p ? p->m_pSHTRCU : nullptr;
78 static inline cds::algo::elimination::record& elimination_record()
80 return Manager::thread_data()->m_EliminationRec;
84 }} // namespace cds::threading
86 #endif // #ifndef __CDS_THREADING_MODEL_H