Public Types | Static Public Member Functions | Static Private Member Functions | List of all members
art::thread_safe_registry_via_id< K, M > Class Template Reference

#include <thread_safe_registry_via_id.h>

Public Types

using collection_type = std::map< K, M >
 
using value_type = typename collection_type::value_type
 

Static Public Member Functions

template<typename C >
static void put (C const &container)
 
static auto emplace (value_type const &value)
 
static auto emplace (K const &key, M const &mapped)
 
static bool empty ()
 
static collection_type const & get ()
 
static bool get (K const &key, M &mapped)
 
static auto instance (bool cleanup=false)
 

Static Private Member Functions

static auto & mutex_ ()
 

Detailed Description

template<typename K, typename M>
class art::thread_safe_registry_via_id< K, M >

Definition at line 33 of file thread_safe_registry_via_id.h.

Member Typedef Documentation

template<typename K , typename M >
using art::thread_safe_registry_via_id< K, M >::collection_type = std::map<K, M>

Definition at line 35 of file thread_safe_registry_via_id.h.

template<typename K , typename M >
using art::thread_safe_registry_via_id< K, M >::value_type = typename collection_type::value_type

Definition at line 36 of file thread_safe_registry_via_id.h.

Member Function Documentation

template<typename K , typename M >
auto art::thread_safe_registry_via_id< K, M >::emplace ( value_type const &  value)
static

Definition at line 85 of file thread_safe_registry_via_id.h.

86  {
87  std::lock_guard sentry{mutex_()};
88  return instance()->emplace(value);
89  }
static auto instance(bool cleanup=false)
template<typename K , typename M >
auto art::thread_safe_registry_via_id< K, M >::emplace ( K const &  key,
M const &  mapped 
)
static

Definition at line 93 of file thread_safe_registry_via_id.h.

94  {
95  std::lock_guard sentry{mutex_()};
96  return instance()->emplace(key, mapped);
97  }
static auto instance(bool cleanup=false)
def key(type, name=None)
Definition: graph.py:13
template<typename K , typename M >
bool art::thread_safe_registry_via_id< K, M >::empty ( )
static

Definition at line 101 of file thread_safe_registry_via_id.h.

102  {
103  std::lock_guard sentry{mutex_()};
104  return instance()->empty();
105  }
static auto instance(bool cleanup=false)
template<typename K , typename M >
auto art::thread_safe_registry_via_id< K, M >::get ( )
static

Definition at line 109 of file thread_safe_registry_via_id.h.

110  {
111  return *instance();
112  }
static auto instance(bool cleanup=false)
template<typename K , typename M >
bool art::thread_safe_registry_via_id< K, M >::get ( K const &  key,
M &  mapped 
)
static

Definition at line 116 of file thread_safe_registry_via_id.h.

117  {
118  std::lock_guard sentry{mutex_()};
119  auto me = instance();
120  auto it = me->find(k);
121  if (it != me->cend()) {
122  mapped = it->second;
123  return true;
124  }
125  return false;
126  }
static auto instance(bool cleanup=false)
template<typename K , typename M >
static auto art::thread_safe_registry_via_id< K, M >::instance ( bool  cleanup = false)
inlinestatic

Definition at line 46 of file thread_safe_registry_via_id.h.

47  {
48  std::lock_guard sentry{mutex_()};
49  static collection_type* me = new collection_type{};
50  if (cleanup) {
51  delete me;
52  me = nullptr;
53  return me;
54  }
55  if (me == nullptr) {
56  // We have been cleaned up and are now being used again.
57  me = new collection_type{};
58  }
59  return me;
60  }
template<typename K , typename M >
static auto& art::thread_safe_registry_via_id< K, M >::mutex_ ( )
inlinestaticprivate

Definition at line 64 of file thread_safe_registry_via_id.h.

65  {
66  static std::recursive_mutex m{};
67  return m;
68  }
template<typename K , typename M >
template<typename C >
void art::thread_safe_registry_via_id< K, M >::put ( C const &  container)
static

Definition at line 74 of file thread_safe_registry_via_id.h.

75  {
76  std::lock_guard sentry{mutex_()};
77  auto me = instance();
78  for (auto const& e : container) {
79  me->emplace(e);
80  }
81  }
const double e
static auto instance(bool cleanup=false)

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