cds  1.5.0
Functions | Variables
cds::threading Namespace Reference

Threading support. More...

Functions

template<class GC >
GC::thread_gc_impl & getGC ()
 Returns thread specific data of GC garbage collector.
 
template<typename RCUtag >
cds::urcu::details::thread_data
< RCUtag > * 
getRCU ()
 Returns RCU thread specific data (thread GC) for current thread. More...
 
template<>
cds::gc::HP::thread_gc_implgetGC< cds::gc::HP > ()
 Get cds::gc::HP thread GC implementation for current thread. More...
 
template<>
cds::gc::HRC::thread_gc_implgetGC< cds::gc::HRC > ()
 Get cds::gc::HRC thread GC implementation for current thread. More...
 
template<>
cds::gc::PTB::thread_gc_implgetGC< cds::gc::PTB > ()
 Get cds::gc::PTB thread GC implementation for current thread. More...
 

Variables

cds::gc::HP::thread_gc_implm_hpManager
 Michael's Hazard Pointer GC thread-specific data.
 
cds::gc::HRC::thread_gc_implm_hrcManager
 Gidenstam's GC thread-specific data.
 
cds::gc::PTB::thread_gc_implm_ptbManager
 Pass The Buck GC thread-specific data.
 
size_t m_nFakeProcessorNumber
 fake "current processor" number
 

Detailed Description

Threading support.

The CDS library requires support from the threads. Each garbage collector manages a control structure on the per-thread basis. The library does not dictate any thread model. To embed the library to your application you should choose appropriate implementation of cds::threading::Manager interface or should provide yourself. The cds::threading::Manager interface manages сds::threading::ThreadData structure that contains GC's thread specific data.

Any cds::threading::Manager implementation is a singleton and it must be accessible from any thread and from any point of your application. Note that you should not mix different implementation of the cds::threading::Manager in your application.

Before compiling of your application you may define one of CDS_THREADING_xxx macro in cds/user_setup/threading.h file:

These macros select appropriate implementation of cds::threading::Manager class. The child namespaces of cds::threading provide suitable implementation and import it to cds::threading by using using directive (or by using inline namespace if the compiler supports it). So, if you need to call threading manager functions directly you should refer to cds::threading::Manager class.

Note
Usually, you should not use cds::threading::Manager instance directly. You may specify CDS_THREADING_xxx macro when building, everything else will setup automatically when you initialize the library, see How to use libcds.

The interface of cds::threading::Manager class is the following:

class Manager {
public:
// Initialize manager (called by cds::Initialize() )
static void init();
// Terminate manager (called by cds::Terminate() )
static void fini();
// Checks whether current thread is attached to \p libcds feature or not.
static bool isThreadAttached() ;
// This method must be called in beginning of thread execution
// (called by ctor of GC thread object, for example, by ctor of cds::gc::HP::thread_gc)
static void attachThread() ;
// This method must be called in end of thread execution
// (called by dtor of GC thread object, for example, by dtor of cds::gc::HP::thread_gc)
static void detachThread() ;
// Get cds::gc::HP thread GC implementation for current thread
static gc::HP::thread_gc_impl& getHZPGC() ;
// Get cds::gc::HRC thread GC implementation for current thread
static gc::HRC::thread_gc_impl& getHRCGC() ;
// Get cds::gc::PTB thread GC implementation for current thread ;
static gc::PTB::thread_gc_impl& getPTBGC() ;
};

The library's core (dynamic linked library) is free of usage of user-supplied cds::threading::Manager code. cds::threading::Manager is necessary for header-only part of CDS library (for cds::threading::getGC functions).

Each thread that uses libcds data structures should be attached to threading::Manager before using lock-free data structs. See How to use section for details

Note for Windows

When you use Garbage Collectors (GC) provided by libcds in your dll that dynamically loaded by LoadLibrary then there is no way to use __declspec(thread) declaration to support threading model for libcds. MSDN says:

Thus, in case when libcds or a dll that depends on libcds is loaded dynamically by calling LoadLibrary explicitly, you should not use CDS_THREADING_MSVC macro. Instead, you should build your dll projects with CDS_THREADING_WIN_TLS only.

Function Documentation

Get cds::gc::HP thread GC implementation for current thread.

The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution or if you did not use cds::gc::HP. To initialize cds::gc::HP GC you must constuct cds::gc::HP object in the beginning of your application, see How to use libcds

Get cds::gc::HRC thread GC implementation for current thread.

The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution or if you did not use cds::gc::HRC. To initialize cds::gc::HRC GC you must constuct cds::gc::HRC object in the beginning of your application, see How to use libcds

Get cds::gc::PTB thread GC implementation for current thread.

The object returned may be uninitialized if you did not call attachThread in the beginning of thread execution or if you did not use cds::gc::PTB. To initialize cds::gc::PTB GC you must constuct cds::gc::PTB object in the beginning of your application, see How to use libcds

template<typename RCUtag >
cds::urcu::details::thread_data<RCUtag>* cds::threading::getRCU ( )

Returns RCU thread specific data (thread GC) for current thread.

Template argument RCUtag is one of RCU tags


cds 1.5.0 Developed by Maxim Khiszinsky aka khizmax 2007 - 2012
Autogenerated Sat Dec 28 2013 15:04:07 by Doxygen 1.8.5