tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ThreadLocalPointer< T > Class Template Reference

#include <thread_local.hpp>

Collaboration diagram for ThreadLocalPointer< T >:

Public Member Functions

 ThreadLocalPointer ()
 
 ~ThreadLocalPointer ()
 
T * get () const
 
void set (T *val)
 
T * operator-> () const
 
T & operator* () const
 

Static Private Attributes

static LOCAL_POINTER_ANNOTATION T * thr_local_key
 

Detailed Description

template<class T>
class ThreadLocalPointer< T >

Copyright (C) 2011 University of Rochester Department of Computer Science and Lehigh University Department of Computer Science and Engineering

License: Modified BSD Please see the file LICENSE.RSTM for licensing information To use a ThreadLocalPointer, declare one in a header like this: extern ThreadLocalPointer<foo> my_foo;

Then you must back the pointer in a cpp file like this: ThreadLocalPointer<foo> currentHeap; if defined(LOCAL_POINTER_ANNOTATION) template <> LOCAL_POINTER_ANNOTATION foo* ThreadLocalPointer<foo>::thr_local_key = NULL; #endif This if block serves three roles:

  • It includes files as necessary for different pthread implementations
  • It hides differences between VisualC++ and GCC syntax
  • It makes sure that a valid thread-local option is specified so that subsequent #ifs don't have to do error checking Hide the fact that some of our platforms use pthread_getspecific while others use os-specific thread local storage mechanisms. In all cases, if you instantiate one of these with a T, then you'll get a thread-local pointer to a T that is easy to access and platform independent

Constructor & Destructor Documentation

template<class T >
ThreadLocalPointer< T >::ThreadLocalPointer ( )
inline

Perform global initialization of the thread key, if applicable. Note that we have a default value of NULL. You can't store a NULL value in this thread-local pointer if you want to do subsequent tests to ensure that the variable is initialized for your thread.

template<class T >
ThreadLocalPointer< T >::~ThreadLocalPointer ( )
inline

Member Function Documentation

template<class T >
T* ThreadLocalPointer< T >::get ( ) const
inline
template<class T >
T& ThreadLocalPointer< T >::operator* ( ) const
inline
template<class T >
T* ThreadLocalPointer< T >::operator-> ( ) const
inline
template<class T >
void ThreadLocalPointer< T >::set ( T *  val)
inline

Member Data Documentation

template<class T >
LOCAL_POINTER_ANNOTATION T* ThreadLocalPointer< T >::thr_local_key
staticprivate

either declare a key for interfacing to PTHREAD thread local storage, or else declare a static thread-local var of type T*


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