Lunchbox  1.8.0
Public Member Functions | List of all members
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 >:

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.

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

Definition at line 42 of file perThread.h.

Constructor & Destructor Documentation

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

Construct a new per-thread variable.

Version
1.0

Definition at line 106 of file perThread.h.

template<class T , void(*)(T *) D>
lunchbox::PerThread< T, D >::~PerThread ( )

Destruct the per-thread variable.

Version
1.0

Definition at line 110 of file perThread.h.

Member Function Documentation

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

Definition at line 127 of file perThread.h.

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

+ Here is the caller graph for this function:

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

Definition at line 132 of file perThread.h.

template<class T , void(*)(T *) D>
bool lunchbox::PerThread< T, D >::isValid ( ) const
Returns
true if the thread-local storage holds a non-0 pointer.
Version
1.0

Definition at line 153 of file perThread.h.

template<class T , void(*)(T *) D>
bool lunchbox::PerThread< T, D >::operator! ( ) const
Returns
true if the thread-local storage holds a 0 pointer.
Version
1.0

Definition at line 148 of file perThread.h.

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 88 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 65 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 68 of file perThread.h.

References lunchbox::className().

+ Here is the call graph for this function:

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

Access the thread-local object.

Version
1.0

Definition at line 137 of file perThread.h.

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

Access the thread-local object.

Version
1.0

Definition at line 143 of file perThread.h.

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

Assign an object to the thread-local storage.

Version
1.0

Definition at line 114 of file perThread.h.

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

Assign an object from another thread-local storage.

Version
1.0

Definition at line 121 of file perThread.h.

References lunchbox::TLS::get().

+ Here is the call graph for this function:

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 75 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 82 of file perThread.h.


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