Embedded Multicore Building Blocks V1.0.0
Public Member Functions | List of all members
embb::base::ThreadSpecificStorage< Type > Class Template Reference

Represents thread-specific storage (TSS). More...

#include <thread_specific_storage.h>

Public Member Functions

 ThreadSpecificStorage ()
 Creates the TSS and default initializes all slots. More...
 
template<typename Initializer1 , ... >
 ThreadSpecificStorage (Initializer1 initializer1,...)
 Creates the TSS and initializes all slots with up to four constructor arguments. More...
 
 ~ThreadSpecificStorage ()
 Destroys the TSS and frees allocated memory for the TSS slots. More...
 
Type & Get ()
 Returns a reference to the TSS slot of the current thread. More...
 
const Type & Get () const
 Returns a const reference to the TSS slot of the current thread. More...
 

Detailed Description

template<typename Type>
class embb::base::ThreadSpecificStorage< Type >

Represents thread-specific storage (TSS).

Provides for each thread a separate slot storing an object of the given type.

Template Parameters
TypeType of the objects

Constructor & Destructor Documentation

template<typename Type >
embb::base::ThreadSpecificStorage< Type >::ThreadSpecificStorage ( )

Creates the TSS and default initializes all slots.

Exceptions
NoMemoryExceptionif not enough memory is available to allocate the TSS slots
Dynamic memory allocation
Dynamically allocates embb::base::Thread::GetThreadsMaxCount() pointers and slots of the TSS type
Concurrency
Not thread-safe
template<typename Type >
template<typename Initializer1 , ... >
embb::base::ThreadSpecificStorage< Type >::ThreadSpecificStorage ( Initializer1  initializer1,
  ... 
)
explicit

Creates the TSS and initializes all slots with up to four constructor arguments.

The TSS objects are created by calling their constructor as follows: Type(initializer1, ...).

Exceptions
NoMemoryExceptionif not enough memory is available to allocate the TSS slots
Dynamic memory allocation
Dynamically allocates embb::base::Thread::GetThreadsMaxCount() pointers and slots of the TSS type
Concurrency
Not thread-safe
Parameters
[in]initializer1First argument for constructor
...
template<typename Type >
embb::base::ThreadSpecificStorage< Type >::~ThreadSpecificStorage ( )

Destroys the TSS and frees allocated memory for the TSS slots.

Member Function Documentation

template<typename Type >
Type& embb::base::ThreadSpecificStorage< Type >::Get ( )

Returns a reference to the TSS slot of the current thread.

Returns
Reference to TSS slot
Exceptions
embb::base::ErrorExceptionif the maximum number of threads has been exceeded
Concurrency
Thread-safe and lock-free
See also
Get() const
template<typename Type >
const Type& embb::base::ThreadSpecificStorage< Type >::Get ( ) const

Returns a const reference to the TSS slot of the current thread.

Returns
Constant reference to TSS slot
Exceptions
embb::base::ErrorExceptionif the maximum number of threads has been exceeded
Concurrency
Thread-safe and lock-free
See also
Get()