CS::Threading::ThreadLocal< T > Class Template Reference
Thread local storage of arbitrary C++ objects. More...
#include <csutil/threading/tls.h>
Inheritance diagram for CS::Threading::ThreadLocal< T >:
Public Member Functions | |
bool | HasValue () const |
Checks whether an instance was ever created for the current thread. | |
operator T & () const | |
Access object for current thread (create, if necessary). | |
T & | operator* () const |
Access object for current thread (create, if necessary). | |
T * | operator-> () const |
Access object for current thread (create, if necessary). | |
ThreadLocal & | operator= (const T &other) |
Assign an instance to the object for the current thread (create, if necessary). |
Detailed Description
template<typename T>
class CS::Threading::ThreadLocal< T >
Thread local storage of arbitrary C++ objects.
Stores an arbitrary object in a TLS slot, automatically creating an instance and destroying it when the thread exits.
- Remarks:
- Actually, an object instance is allocated on the heap. For small objects (integral values, simple pointers) it may be more efficient to use ThreadLocalBase directly or to coalesce multiple such small objects into a larger struct which is then stored thread locally (instead of having multiple small TLS slots).
Definition at line 86 of file tls.h.
Member Function Documentation
template<typename T >
bool CS::Threading::ThreadLocal< T >::HasValue | ( | ) | const [inline] |
template<typename T >
CS::Threading::ThreadLocal< T >::operator T & | ( | ) | const [inline] |
template<typename T >
T& CS::Threading::ThreadLocal< T >::operator* | ( | ) | const [inline] |
template<typename T >
T* CS::Threading::ThreadLocal< T >::operator-> | ( | ) | const [inline] |
template<typename T >
ThreadLocal& CS::Threading::ThreadLocal< T >::operator= | ( | const T & | other | ) | [inline] |
The documentation for this class was generated from the following file:
- csutil/threading/tls.h
Generated for Crystal Space 2.0 by doxygen 1.6.1