CppCMS
|
Thread specific pointer. More...
#include <booster/booster/thread.h>
Public Member Functions | |
thread_specific_ptr () | |
~thread_specific_ptr () | |
T * | get () const |
T * | operator-> () const |
T & | operator* () const |
void | reset (T *new_val=0) |
T * | release () |
Thread specific pointer.
Thread specific pointer is NULL for all threads. So on first use it is expected to be initialized.
The object would be destroyed when the thread exists. If thread_specific_ptr was destroyed before the thread that uses it exited the object would still exist and would be cleaned up on thread exit.
Of course an access to thread_specific_ptr object would lead to undefined behavior and would likely is going to crash your program.
On Windows platform, when CppCMS and Booster are compiled statically (not used as DLL) then TLS cleanup for the threads that where not created with booster::thread would not be executed.
So when using thread_specific_ptr on Windows platform make sure that you do one of the following:
|
inline |
Create a new thread specific pointer
|
inline |
Destroy the thread specific pointer
|
inline |
Get thread specific value, if not initialized returns NULL
|
inline |
Dereference pointer, if it is NULL the behavior is undefined
|
inline |
Dereference pointer, if it is NULL the behavior is undefined
|
inline |
Release exiting pointer and set thread specific pointer to 0.
The caller is responsible to destroy the returned object
|
inline |
Reset the thread specific pointer and set its value to new_val.
If previous object was not NULL it would be destroyed