49 template <
typename Key,
typename Value>
59 Value&
at(
const Key& key,
const std::string& what_arg =
"Key not found")
61 std::lock_guard<std::recursive_mutex> lock(this->
_mutex);
71 catch (
const std::out_of_range&)
83 auto find(
const Key& key,
const std::string& what_arg = {})
85 std::lock_guard<std::recursive_mutex> lock(this->
_mutex);
91 if (!what_arg.empty() && it == this->_container.end())
104 std::lock_guard<std::recursive_mutex> lock(this->
_mutex);
118 std::lock_guard<std::recursive_mutex> lock(this->
_mutex);
137 typename std::map<Key, Value>::iterator
erase(
typename std::map<Key, Value>::iterator position)
139 std::lock_guard<std::recursive_mutex> lock(this->
_mutex);
151 std::size_t
count(
const Key& key)
const
153 std::lock_guard<std::recursive_mutex> lock(this->
_mutex);
157 std::pair<typename std::map<Key, Value>::iterator,
bool>
insert(
const Key& key,
const Value& value)
159 std::lock_guard<std::recursive_mutex> lock(this->
_mutex);
178 std::pair<typename std::map<Key, Value>::iterator,
bool>
insert(
const std::pair<Key, Value>& pair)
180 std::lock_guard<std::recursive_mutex> lock(this->
_mutex);
std::map< Key, Value > _container
Definition thread_safe_container.hpp:156
std::atomic< bool > _is_being_modified
Definition thread_safe_container.hpp:157
thread_safe_container()=default
std::recursive_mutex _mutex
Definition thread_safe_container.hpp:155
Thread-safe wrapper for std::map.
Definition thread_safe_map.hpp:51
std::pair< typename std::map< Key, Value >::iterator, bool > insert(const std::pair< Key, Value > &pair)
Inserts a new element or assigns to the current element if the key already exists.
Definition thread_safe_map.hpp:178
Value & operator[](const Key &key)
Access or insert specified element.
Definition thread_safe_map.hpp:102
std::map< Key, Value >::iterator erase(typename std::map< Key, Value >::iterator position)
Removes the element at the specified position.
Definition thread_safe_map.hpp:137
auto find(const Key &key, const std::string &what_arg={})
Finds an element with a specific key.
Definition thread_safe_map.hpp:83
std::size_t erase(const Key &key)
Removes the element with the specified key.
Definition thread_safe_map.hpp:116
std::size_t count(const Key &key) const
Returns the number of elements matching specific key.
Definition thread_safe_map.hpp:151
std::pair< typename std::map< Key, Value >::iterator, bool > insert(const Key &key, const Value &value)
Definition thread_safe_map.hpp:157
Value & at(const Key &key, const std::string &what_arg="Key not found")
Access specified element with bounds checking.
Definition thread_safe_map.hpp:59
A Cbeam-specific out_of_range error that also behaves like std::out_of_range.
Definition out_of_range.hpp:50
A Cbeam-specific runtime error that also acts like std::runtime_error.
Definition runtime_error.hpp:46
A helper that sets the given variable to a new value, and restores the original value on destruction.
Definition scoped_set.hpp:61
Offers advanced container types with unique approaches to stability and interprocess sharing....
Definition buffer.hpp:44