2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef CDSLIB_THREADING_MODEL_H
32 #define CDSLIB_THREADING_MODEL_H
34 #include <cds/threading/details/_common.h>
35 #include <cds/user_setup/threading.h>
36 #include <cds/threading/details/auto_detect.h>
38 namespace cds { namespace threading {
40 /// Returns thread specific data of \p GC garbage collector
41 template <class GC> typename GC::thread_gc_impl& getGC();
43 /// Returns RCU thread specific data (thread GC) for current thread
45 Template argument \p RCUtag is one of \ref cds_urcu_tags "RCU tags"
47 template <typename RCUtag> cds::urcu::details::thread_data<RCUtag> * getRCU();
49 /// Get cds::gc::HP thread GC implementation for current thread
51 The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution
52 or if you did not use cds::gc::HP.
53 To initialize cds::gc::HP GC you must constuct cds::gc::HP object in the beginning of your application,
54 see \ref cds_how_to_use "How to use libcds"
57 inline cds::gc::HP::thread_gc_impl& getGC<cds::gc::HP>()
59 return Manager::getHZPGC();
62 /// Get cds::gc::DHP thread GC implementation for current thread
64 The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution
65 or if you did not use cds::gc::DHP.
66 To initialize cds::gc::DHP GC you must constuct cds::gc::DHP object in the beginning of your application,
67 see \ref cds_how_to_use "How to use libcds"
70 inline cds::gc::DHP::thread_gc_impl& getGC<cds::gc::DHP>()
72 return Manager::getDHPGC();
77 inline cds::urcu::details::thread_data<cds::urcu::general_instant_tag> * getRCU<cds::urcu::general_instant_tag>()
79 return Manager::thread_data()->m_pGPIRCU;
82 inline cds::urcu::details::thread_data<cds::urcu::general_buffered_tag> * getRCU<cds::urcu::general_buffered_tag>()
84 return Manager::thread_data()->m_pGPBRCU;
87 inline cds::urcu::details::thread_data<cds::urcu::general_threaded_tag> * getRCU<cds::urcu::general_threaded_tag>()
89 return Manager::thread_data()->m_pGPTRCU;
91 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
93 inline cds::urcu::details::thread_data<cds::urcu::signal_buffered_tag> * getRCU<cds::urcu::signal_buffered_tag>()
95 ThreadData * p = Manager::thread_data();
96 return p ? p->m_pSHBRCU : nullptr;
99 inline cds::urcu::details::thread_data<cds::urcu::signal_threaded_tag> * getRCU<cds::urcu::signal_threaded_tag>()
101 ThreadData * p = Manager::thread_data();
102 return p ? p->m_pSHTRCU : nullptr;
106 static inline cds::algo::elimination::record& elimination_record()
108 return Manager::thread_data()->m_EliminationRec;
112 }} // namespace cds::threading
114 #endif // #ifndef CDSLIB_THREADING_MODEL_H