All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::TLS< T > Class Template Reference

Thread Local Storage implementation. More...

#include <Radiant/Thread.hpp>

Public Member Functions

std::list< T > all () const
 Get all instances of the variable Returns a list of all instances of the TLS variable from different threads. More...
 
T & get ()
 Get the calling thread instance of the TLS variable. More...
 
 operator T & ()
 Get the calling thread instance of the TLS variable. More...
 
TLS< T > & operator= (const T &t)
 Assign the underlying value. More...
 
void setAll (const T &t)
 Set all instances of the variable to the given value. More...
 
 TLS ()
 Constructs TLS variable with default constructor.
 
 TLS (const T &t)
 Construct a TLS variable with the given default value. More...
 
 TLS (const TLS &t)
 Construct a copy. More...
 

Detailed Description

template<typename T>
class Radiant::TLS< T >

Thread Local Storage implementation.

Do something like Radiant::TLS<int> foo = 5; and after that you can just use the foo as int

Constructor & Destructor Documentation

template<typename T >
Radiant::TLS< T >::TLS ( const T &  t)
inline

Construct a TLS variable with the given default value.

Parameters
tdefault value
template<typename T >
Radiant::TLS< T >::TLS ( const TLS< T > &  t)
inline

Construct a copy.

Parameters
tobject to copy

Member Function Documentation

template<typename T >
std::list<T> Radiant::TLS< T >::all ( ) const
inline

Get all instances of the variable Returns a list of all instances of the TLS variable from different threads.

Returns
list of all instances in different threads
template<typename T >
T& Radiant::TLS< T >::get ( )
inline

Get the calling thread instance of the TLS variable.

Returns
variable instance in calling thread
template<typename T >
Radiant::TLS< T >::operator T & ( )
inline

Get the calling thread instance of the TLS variable.

Returns
variable instance in calling thread
template<typename T >
TLS<T>& Radiant::TLS< T >::operator= ( const T &  t)
inline

Assign the underlying value.

Parameters
tValue to assign
Returns
Reference to self
template<typename T >
void Radiant::TLS< T >::setAll ( const T &  t)
inline

Set all instances of the variable to the given value.

Parameters
tvalue to set