CppCMS
Public Member Functions
booster::thread_specific_ptr< T > Class Template Reference

Thread specific pointer. More...

#include <booster/booster/thread.h>

List of all members.

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 ()

Detailed Description

template<typename T>
class booster::thread_specific_ptr< T >

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.

Note:

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:


Constructor & Destructor Documentation

template<typename T >
booster::thread_specific_ptr< T >::thread_specific_ptr ( ) [inline]

Create a new thread specific pointer

template<typename T >
booster::thread_specific_ptr< T >::~thread_specific_ptr ( ) [inline]

Destroy the thread specific pointer


Member Function Documentation

template<typename T >
T* booster::thread_specific_ptr< T >::get ( ) const [inline]

Get thread specific value, if not initialized returns NULL

template<typename T >
T& booster::thread_specific_ptr< T >::operator* ( ) const [inline]

Dereference pointer, if it is NULL the behavior is undefined

template<typename T >
T* booster::thread_specific_ptr< T >::operator-> ( ) const [inline]

Dereference pointer, if it is NULL the behavior is undefined

template<typename T >
T* booster::thread_specific_ptr< T >::release ( ) [inline]

Release exiting pointer and set thread specific pointer to 0.

The caller is responsible to destroy the returned object

template<typename T >
void booster::thread_specific_ptr< T >::reset ( T *  new_val = 0) [inline]

Reset the thread specific pointer and set its value to new_val.

If previous object was not NULL it would be destroyed


The documentation for this class was generated from the following file: