Lunchbox  1.6.0
Public Member Functions
lunchbox::PerThread< T, D > Class Template Reference

Implements thread-specific storage for C++ objects. More...

#include <perThread.h>

+ Inheritance diagram for lunchbox::PerThread< T, D >:
+ Collaboration diagram for lunchbox::PerThread< T, D >:

List of all members.

Public Member Functions

 PerThread ()
 Construct a new per-thread variable.
 ~PerThread ()
 Destruct the per-thread variable.
PerThread< T, D > & operator= (const T *data)
 Assign an object to the thread-local storage.
PerThread< T, D > & operator= (const PerThread< T, D > &rhs)
 Assign an object from another thread-local storage.
T * get ()
const T * get () const
T * operator-> ()
 Access the thread-local object.
const T * operator-> () const
 Access the thread-local object.
T & operator* ()
const T & operator* () const
bool operator== (const PerThread &rhs) const
bool operator== (const T *rhs) const
bool operator!= (const T *rhs) const
bool operator! () const
bool isValid () const

Detailed Description

template<class T, void(*)(T *) D = &perThreadDelete< T >>
class lunchbox::PerThread< T, D >

Implements thread-specific storage for C++ objects.

The default destructor function deletes the object on thread exit.

To instantiate the template code for this class, applications have to include pthread.h before this file. The pthread.h header is not automatically included to avoid hard to resolve type conflicts with other header files on Windows.

Parameters:
Tthe type of data to store in thread-local storage
Dthe destructor callback function.

Definition at line 50 of file perThread.h.


Constructor & Destructor Documentation

template<class T, void(*)(T *) D = &perThreadDelete< T >>
lunchbox::PerThread< T, D >::PerThread ( )

Construct a new per-thread variable.

Version:
1.0
template<class T, void(*)(T *) D = &perThreadDelete< T >>
lunchbox::PerThread< T, D >::~PerThread ( )

Destruct the per-thread variable.

Version:
1.0

Member Function Documentation

template<class T, void(*)(T *) D = &perThreadDelete< T >>
T* lunchbox::PerThread< T, D >::get ( )
Returns:
the held object pointer.
Version:
1.0

Referenced by lunchbox::PerThread< T, D >::operator==().

+ Here is the caller graph for this function:

template<class T, void(*)(T *) D = &perThreadDelete< T >>
const T* lunchbox::PerThread< T, D >::get ( ) const
Returns:
the held object pointer.
Version:
1.0
template<class T, void(*)(T *) D = &perThreadDelete< T >>
bool lunchbox::PerThread< T, D >::isValid ( ) const
Returns:
true if the thread-local storage holds a non-0 pointer.
Version:
1.0
template<class T, void(*)(T *) D = &perThreadDelete< T >>
bool lunchbox::PerThread< T, D >::operator! ( ) const
Returns:
true if the thread-local storage holds a 0 pointer.
Version:
1.0
template<class T, void(*)(T *) D = &perThreadDelete< T >>
bool lunchbox::PerThread< T, D >::operator!= ( const T *  rhs) const [inline]
Returns:
true if the thread-local variable holds another object.
Version:
1.0

Definition at line 96 of file perThread.h.

template<class T, void(*)(T *) D = &perThreadDelete< T >>
T& lunchbox::PerThread< T, D >::operator* ( ) [inline]
Returns:
the held object reference.
Version:
1.0

Definition at line 73 of file perThread.h.

References lunchbox::className().

+ Here is the call graph for this function:

template<class T, void(*)(T *) D = &perThreadDelete< T >>
const T& lunchbox::PerThread< T, D >::operator* ( ) const [inline]
Returns:
the held object reference.
Version:
1.0

Definition at line 76 of file perThread.h.

References lunchbox::className().

+ Here is the call graph for this function:

template<class T, void(*)(T *) D = &perThreadDelete< T >>
T* lunchbox::PerThread< T, D >::operator-> ( )

Access the thread-local object.

Version:
1.0
template<class T, void(*)(T *) D = &perThreadDelete< T >>
const T* lunchbox::PerThread< T, D >::operator-> ( ) const

Access the thread-local object.

Version:
1.0
template<class T, void(*)(T *) D = &perThreadDelete< T >>
PerThread<T, D>& lunchbox::PerThread< T, D >::operator= ( const T *  data)

Assign an object to the thread-local storage.

Version:
1.0
template<class T, void(*)(T *) D = &perThreadDelete< T >>
PerThread<T, D>& lunchbox::PerThread< T, D >::operator= ( const PerThread< T, D > &  rhs)

Assign an object from another thread-local storage.

Version:
1.0
template<class T, void(*)(T *) D = &perThreadDelete< T >>
bool lunchbox::PerThread< T, D >::operator== ( const PerThread< T, D > &  rhs) const [inline]
Returns:
true if the thread-local variables hold the same object.
Version:
1.0

Definition at line 83 of file perThread.h.

References lunchbox::PerThread< T, D >::get().

+ Here is the call graph for this function:

template<class T, void(*)(T *) D = &perThreadDelete< T >>
bool lunchbox::PerThread< T, D >::operator== ( const T *  rhs) const [inline]
Returns:
true if the thread-local variable holds the same object.
Version:
1.0

Definition at line 90 of file perThread.h.


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