ATLAS Offline Software
|
A thread-local storage wrapper for the user actions. More...
#include <ThreadSpecificUserAction.h>
Public Types | |
using | ThreadMapKey_t = std::thread::id |
using | ThreadMapVal_t = ActionType * |
using | ThreadMapHash_t = std::hash< ThreadMapKey_t > |
using | ThreadMap_t = tbb::concurrent_unordered_map< ThreadMapKey_t, ThreadMapVal_t, ThreadMapHash_t > |
using | const_iterator = typename ThreadMap_t::const_iterator |
Public Member Functions | |
~ThreadSpecificUserAction () | |
Destructor will clean up the thread-local storage. More... | |
ActionType * | get () |
Get the object of the current thread. More... | |
void | set (std::unique_ptr< ActionType > action) |
Assign the object of the current thread. More... | |
const_iterator | begin () const |
Constant-access iteration over the action map. More... | |
const_iterator | end () const |
Constant-access iteration over the action map. More... | |
template<class ResultType , class Mapper , class Reducer > | |
void | accumulate (ResultType &result, Mapper mapOp, Reducer reduceOp) |
Accumulate results across user actions with specified operations. More... | |
Private Attributes | |
ThreadMap_t | m_threadMap |
The wrapped thread-local storage container. More... | |
A thread-local storage wrapper for the user actions.
This container is implemented as a wrapper for a concurrent map keyed by std thread ID. It is thus fully thread-safe (in theory).
The thread-local storage is cleared in the destructor for now, at least until TBB's concurrent containers support move semantics and unique_ptr.
Definition at line 30 of file ThreadSpecificUserAction.h.
using G4UA::ThreadSpecificUserAction< ActionType >::const_iterator = typename ThreadMap_t::const_iterator |
Definition at line 41 of file ThreadSpecificUserAction.h.
using G4UA::ThreadSpecificUserAction< ActionType >::ThreadMap_t = tbb::concurrent_unordered_map < ThreadMapKey_t, ThreadMapVal_t, ThreadMapHash_t > |
Definition at line 39 of file ThreadSpecificUserAction.h.
using G4UA::ThreadSpecificUserAction< ActionType >::ThreadMapHash_t = std::hash<ThreadMapKey_t> |
Definition at line 38 of file ThreadSpecificUserAction.h.
using G4UA::ThreadSpecificUserAction< ActionType >::ThreadMapKey_t = std::thread::id |
Definition at line 35 of file ThreadSpecificUserAction.h.
using G4UA::ThreadSpecificUserAction< ActionType >::ThreadMapVal_t = ActionType* |
Definition at line 36 of file ThreadSpecificUserAction.h.
|
inline |
Destructor will clean up the thread-local storage.
Would prefer to do this automatically with unique_ptr.
Definition at line 45 of file ThreadSpecificUserAction.h.
|
inline |
Accumulate results across user actions with specified operations.
Takes an initial result object to accumulate into and two function-like objects:
The operations get wrapped in std::function which allows for some constrained flexibility while avoiding difficulties in template parameter determination in the arguments.
Definition at line 88 of file ThreadSpecificUserAction.h.
|
inline |
Constant-access iteration over the action map.
Definition at line 67 of file ThreadSpecificUserAction.h.
|
inline |
Constant-access iteration over the action map.
Definition at line 72 of file ThreadSpecificUserAction.h.
|
inline |
|
inline |
Assign the object of the current thread.
Memory management must be handled manually for now.
Definition at line 61 of file ThreadSpecificUserAction.h.
|
private |
The wrapped thread-local storage container.
Definition at line 103 of file ThreadSpecificUserAction.h.