LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
fhicl::detail::per_thread_holder< T > Class Template Reference

#include "per_thread_holder.h"

Public Member Functions

T & slot_for_current_thread ()
 

Private Types

using registry_t = tbb::concurrent_hash_map< std::thread::id, T, thread_hash_compare >
 
using accessor = typename registry_t::accessor
 

Private Member Functions

T & slot_for (std::thread::id id)
 

Private Attributes

registry_t registry_
 

Detailed Description

template<typename T>
class fhicl::detail::per_thread_holder< T >

Definition at line 23 of file per_thread_holder.h.

Member Typedef Documentation

template<typename T>
using fhicl::detail::per_thread_holder< T >::accessor = typename registry_t::accessor
private

Definition at line 26 of file per_thread_holder.h.

template<typename T>
using fhicl::detail::per_thread_holder< T >::registry_t = tbb::concurrent_hash_map<std::thread::id, T, thread_hash_compare>
private

Definition at line 25 of file per_thread_holder.h.

Member Function Documentation

template<typename T>
T& fhicl::detail::per_thread_holder< T >::slot_for ( std::thread::id  id)
inlineprivate

Definition at line 37 of file per_thread_holder.h.

38  {
39  // Lock held on key's map entry until the function returns.
40  accessor access_token;
41  if (not registry_.insert(access_token, id)) {
42  // Entry already exists; return cached entry.
43  return access_token->second;
44  }
45 
46  access_token->second = T{};
47  return access_token->second;
48  }
typename registry_t::accessor accessor
template<typename T>
T& fhicl::detail::per_thread_holder< T >::slot_for_current_thread ( )
inline

Definition at line 30 of file per_thread_holder.h.

Referenced by fhicl::detail::TableMemberRegistry::instance_(), and fhicl::NameStackRegistry::instance_().

31  {
32  return slot_for(std::this_thread::get_id());
33  }
T & slot_for(std::thread::id id)

Member Data Documentation

template<typename T>
registry_t fhicl::detail::per_thread_holder< T >::registry_
private

Definition at line 50 of file per_thread_holder.h.


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