Public Member Functions
|T &||cast ()|
|operator T & (void)|
Static Public Member Functions
|static void||static_destruction (void *t)|
|Destroy the part that is common to all threads. |
|static void||static_init (void *t, void const *)|
|Initialize the part that is common to all threads. |
|static void||static_init (void)|
This class implements transparent acces to the posix tools arround pthread_getspecific and enable you the view of a per thread variable with static storage class of type T.
A variable of type
specific<T> should never be of storage class automatic. First of all this makes not much sense, usual variables on the stack fulfill this role perfectly. Then this would very much likely crash your program...
Use such a variable in your code (almost) as you would use a variable of storage class ``static'', so like a variable that you declared ``static'' or in the global scope of a program file. You can read it or assign to it with no problem.
The ``almost'' is for some cases where C++ due to its expressional incapacities pretends not to know what you'd like to do with the variable. In particular this happens when you pass such a variable to a function with a ``...'' parameter list, such as par_report. Here you have to cast your variable to T. Since this may turn your code unreadable we provide methods named ``cast()'' for that purpose.
All of this only makes sense for if the variable is of static linkage. A specific variable has no constructor of its own so you have to initialize it statically. Use the macro PAR_SYS_SPECIFIC_CONST() for it as in
static par::sys::once< double > specificVal = PAR_SYS_SPECIFIC_CONST(specificVal);
The destructor of a specific variable is quite particular.
Since we assume that this is of static linkage it should be called exactly once by the very last remaining thread. All other per-thread copies of the variables are freed by calls to destroy(void*) when the individual threads terminate but the one of this thread here must be destroyed before the destructor for key_t is called.
|T& par::sys::specific< T >::cast||(||void||)||
|void par::sys::specific< T >::dynamic_init||(||void||)||
|par::sys::specific< T >::operator T &||(||void||)||
|static void par::sys::specific< T >::static_destruction||(||void *||t||)||
|static void par::sys::specific< T >::static_init||(||void *||t,|
|void const *|
|static void par::sys::specific< T >::static_init||(||void||)||