ROSE 0.11.145.192
Public Member Functions | List of all members
Sawyer::MultiInstanceTls< T > Class Template Reference

Description

template<typename T>
class Sawyer::MultiInstanceTls< T >

Thread local data per object instance.

This is useful when you have a class non-static data member that needs to be thread-local.

struct MyClass {
static SAWYER_THREAD_LOCAL int foo; // static thread-local using __thread, thread_local, etc.
MultiInstanceTls<int> bar; // per-instance thread local
};
MyClass a, b;
a.bar = 5;
b.bar = 6;
assert(a.bar + 1 == b.bar);
Thread local data per object instance.

where SAWYER_THREAD_LOCAL is a macro expanding to, perhaps, "__thread". C++ only allows thread-local global variables or static member data, as with foo above. That means that a.foo and b.foo alias one another. But if you need some member data to be thread-local per object, you can declare it as MultiInstanceTls<T>. For instance, a.bar and b.bar are different storage locations, and are also thread-local.

Definition at line 190 of file Synchronization.h.

#include <Sawyer/Synchronization.h>

Public Member Functions

 MultiInstanceTls ()
 Default-constructed value.
 
 MultiInstanceTls (const T &value)
 Initialize value.
 
 MultiInstanceTls (const MultiInstanceTls &other)
 
MultiInstanceTlsoperator= (const T &value)
 Assignment operator.
 
MultiInstanceTlsoperator= (const MultiInstanceTls &other)
 
T & operator* ()
 
const T & operator* () const
 
T * operator-> ()
 
const T * operator-> () const
 
 operator T () const
 Implicit conversion to enclosed type.
 
T & get ()
 Get interior object.
 
const T & get () const
 Get interior object.
 

Constructor & Destructor Documentation

◆ MultiInstanceTls() [1/3]

template<typename T >
Sawyer::MultiInstanceTls< T >::MultiInstanceTls ( )
inline

Default-constructed value.

Definition at line 202 of file Synchronization.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insert().

◆ MultiInstanceTls() [2/3]

template<typename T >
Sawyer::MultiInstanceTls< T >::MultiInstanceTls ( const T &  value)
inline

Initialize value.

Definition at line 209 of file Synchronization.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insert().

◆ MultiInstanceTls() [3/3]

template<typename T >
Sawyer::MultiInstanceTls< T >::MultiInstanceTls ( const MultiInstanceTls< T > &  other)
inline

Definition at line 215 of file Synchronization.h.

◆ ~MultiInstanceTls()

template<typename T >
Sawyer::MultiInstanceTls< T >::~MultiInstanceTls ( )
inline

Definition at line 236 of file Synchronization.h.

Member Function Documentation

◆ operator=() [1/2]

template<typename T >
MultiInstanceTls & Sawyer::MultiInstanceTls< T >::operator= ( const T &  value)
inline

Assignment operator.

Definition at line 222 of file Synchronization.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insert().

◆ operator=() [2/2]

template<typename T >
MultiInstanceTls & Sawyer::MultiInstanceTls< T >::operator= ( const MultiInstanceTls< T > &  other)
inline

Definition at line 229 of file Synchronization.h.

◆ get() [1/2]

template<typename T >
T & Sawyer::MultiInstanceTls< T >::get ( )
inline

Get interior object.

Definition at line 244 of file Synchronization.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybeDefault().

◆ get() [2/2]

template<typename T >
const T & Sawyer::MultiInstanceTls< T >::get ( ) const
inline

Get interior object.

Definition at line 249 of file Synchronization.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybeDefault().

◆ operator*() [1/2]

template<typename T >
T & Sawyer::MultiInstanceTls< T >::operator* ( )
inline

Definition at line 256 of file Synchronization.h.

◆ operator*() [2/2]

template<typename T >
const T & Sawyer::MultiInstanceTls< T >::operator* ( ) const
inline

Definition at line 260 of file Synchronization.h.

◆ operator->() [1/2]

template<typename T >
T * Sawyer::MultiInstanceTls< T >::operator-> ( )
inline

Definition at line 264 of file Synchronization.h.

◆ operator->() [2/2]

template<typename T >
const T * Sawyer::MultiInstanceTls< T >::operator-> ( ) const
inline

Definition at line 268 of file Synchronization.h.

◆ operator T()

template<typename T >
Sawyer::MultiInstanceTls< T >::operator T ( ) const
inline

Implicit conversion to enclosed type.

This is so that the data member can be used as if it were type T rather than a MultiInstanceTls object.

Definition at line 275 of file Synchronization.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybeDefault().


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