18 #ifndef LUNCHBOX_PERTHREADREF_H
19 #define LUNCHBOX_PERTHREADREF_H
21 #include <lunchbox/tls.h>
27 template<
typename T >
class PerThreadRef :
public boost::noncopyable
69 {
return (
get() == rhs.
get( )); }
76 {
return (
get()==rhs ); }
83 {
return (
get()!=rhs ); }
111 template<
typename T >
117 tls_.set( static_cast<const void*>( data.
get( )));
123 template<
typename T >
130 tls_.set( rhs.tls_.
get( ));
138 return static_cast< const T*
>( tls_.get( ));
143 return static_cast< T*
>( tls_.get( ));
146 template<
typename T >
149 return static_cast< T*
>( tls_.get( ));
152 template<
typename T >
155 LBASSERT( tls_.get( ));
156 return static_cast< T*
>( tls_.get( ));
159 template<
typename T >
162 LBASSERT( tls_.get( ));
163 return static_cast< const T*
>( tls_.get( ));
166 template<
typename T >
169 return tls_.get() == 0;
172 template<
typename T >
175 return tls_.get() != 0;
179 #endif //LUNCHBOX_PERTHREADREF_H
~PerThreadRef()
Destruct a per-thread RefPtr.
bool operator!=(const RefPtr< T > &rhs) const
PerThreadRef< T > & operator=(RefPtr< T > data)
Assign a RefPtr to the thread-local storage.
Abstraction layer and common utilities for multi-threaded programming.
A smart reference pointer, aka boost::intrusive_ptr.
Thread-specific storage for a RefPtr.
RefPtr< const T > get() const
Provides thread-local storage API used by PerThread and PerThreadRef.
PerThreadRef()
Construct a new per-thread RefPtr.
bool operator==(const PerThreadRef &rhs) const