template<class T>
thread_utils::ThreadLocalHolder class

A thread-local storage wrapper.

This container is implemented as a wrapper for a concurrent map keyed by std thread ID. It is thus fully thread-safe (in theory).

This container is non-owning. It doesn't clean up memory. For a corresponding container which owns its objects, see ThreadLocalOwner.

Derived classes

template<class T>
class ThreadLocalOwner
A ThreadLocalHolder which owns its objects.

Public types

using MapKey_t = std::thread::id
using MapVal_t = T*
using MapHash_t = std::hash<MapKey_t>
using ThreadMap_t = tbb::concurrent_unordered_map<MapKey_t, MapVal_t, MapHash_t>

Public functions

auto get() -> T*
Get the object of the current thread.
void set(T* obj)
Assign the object of the current thread.
auto getMap() const -> const ThreadMap_t&
Constant access for iteration, etc.

Protected variables

ThreadMap_t m_threadMap
The wrapped thread-local storage container.