5#ifndef G4ATLASTOOLS__G4UA_THREADACTIONHOLDER_H
6#define G4ATLASTOOLS__G4UA_THREADACTIONHOLDER_H
14#include "tbb/concurrent_unordered_map.h"
29 template<
class ActionType>
49 delete mapPair.second;
56 auto mapPair =
m_threadMap.find( std::this_thread::get_id() );
58 return mapPair->second;
63 void set(std::unique_ptr<ActionType> action) {
64 const auto tid = std::this_thread::get_id();
65 m_threadMap.insert( std::make_pair(tid, action.release()) );
A thread-local storage wrapper for the user actions.
const_iterator end() const
Constant-access iteration over the action map.
tbb::concurrent_unordered_map< ThreadMapKey_t, ThreadMapVal_t, ThreadMapHash_t > ThreadMap_t
ActionType * ThreadMapVal_t
std::hash< ThreadMapKey_t > ThreadMapHash_t
void set(std::unique_ptr< ActionType > action)
Assign the object of the current thread.
std::thread::id ThreadMapKey_t
typename ThreadMap_t::const_iterator const_iterator
const_iterator begin() const
Constant-access iteration over the action map.
ThreadMap_t m_threadMap
The wrapped thread-local storage container.
ActionType * get()
Get the object of the current thread.
~ThreadActionHolder()
Destructor will clean up the thread-local storage.