CrystalSpace

Public API Reference

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 >:

List of all members.

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).
ThreadLocaloperator= (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]

Checks whether an instance was ever created for the current thread.

Definition at line 117 of file tls.h.

template<typename T >
CS::Threading::ThreadLocal< T >::operator T & (  )  const [inline]

Access object for current thread (create, if necessary).

Definition at line 123 of file tls.h.

template<typename T >
T& CS::Threading::ThreadLocal< T >::operator* (  )  const [inline]

Access object for current thread (create, if necessary).

Definition at line 135 of file tls.h.

template<typename T >
T* CS::Threading::ThreadLocal< T >::operator-> (  )  const [inline]

Access object for current thread (create, if necessary).

Definition at line 129 of file tls.h.

template<typename T >
ThreadLocal& CS::Threading::ThreadLocal< T >::operator= ( const T &  other  )  [inline]

Assign an instance to the object for the current thread (create, if necessary).

Definition at line 141 of file tls.h.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1