A concurrent map container which can be stored in persistent memory. This container does not allocate mutex objects internally, but allocates them as static objects. To achieve high concurrency, this container allocates multiple banks, where a bank consists of an actual STL map object and a mutex object.
More...
#include </home/runner/work/metall/metall/include/metall/container/concurrent_map.hpp>
|
| concurrent_map (const _allocator &allocator=_allocator()) |
|
size_type | count (const key_type &key) const |
| Returns the number of elements matching specific key. More...
|
|
size_type | size () const |
| Returns the number of elements in the container. More...
|
|
bool | insert (value_type &&value) |
| Inserts element into the container if the container doesn't already contain an element with an equivalent key. More...
|
|
std::pair< mapped_type &, std::unique_lock< std::mutex > > | scoped_edit (const key_type &key) |
| Provides a way to edit an element exclusively. If no element exists with an equivalent key, this container creates a new element with key. More...
|
|
void | edit (const key_type &key, const std::function< void(mapped_type &mapped_value)> &editor) |
| Provides a way to edit an element exclusively. If no element exists with an equivalent key, this container creates a new element with key. More...
|
|
const_iterator | cbegin () const |
| Returns an iterator to the first element of the map. If the container is empty, the returned iterator will be equal to end(). More...
|
|
const_iterator | cend () const |
| Returns an iterator to the element following the last element of the map. This element acts as a placeholder; attempting to access it results in undefined behavior. More...
|
|
const_iterator | find (const key_type &key) const |
| Finds an element with an equivalent key. More...
|
|
allocator_type | get_allocator () const |
| Returns the allocator associated with the container. More...
|
|
template<typename _key_type, typename _mapped_type, typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
class metall::container::concurrent_map< _key_type, _mapped_type, _compare, _bank_no_hasher, _allocator, k_num_banks >
A concurrent map container which can be stored in persistent memory. This container does not allocate mutex objects internally, but allocates them as static objects. To achieve high concurrency, this container allocates multiple banks, where a bank consists of an actual STL map object and a mutex object.
- Template Parameters
-
_key_type | A key type. |
_mapped_type | A mapped type. |
_compare | A key compare. |
_bank_no_hasher | A key hasher. |
_allocator | An allocator. |
k_num_banks | The number of banks to be allocated. |
- Examples
- concurrent_map.cpp.
◆ key_type
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
◆ mapped_type
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
◆ value_type
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
A value type (i.e., std::pair<const key_type, mapped_type>).
◆ size_type
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
A unsigned integer type (usually std::size_t).
◆ allocator_type
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
◆ const_iterator
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
◆ concurrent_map()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
◆ count()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Returns the number of elements matching specific key.
- Parameters
-
key | A key value of the elements to count. |
- Returns
- The number of elements with key that compares equivalent to key, which is either 1 or 0.
◆ size()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Returns the number of elements in the container.
- Returns
- The number of elements in the container.
◆ insert()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Inserts element into the container if the container doesn't already contain an element with an equivalent key.
- Parameters
-
value | An element value to insert. |
- Returns
- A bool denoting whether the insertion took place.
◆ scoped_edit()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Provides a way to edit an element exclusively. If no element exists with an equivalent key, this container creates a new element with key.
- Parameters
-
key | A key of the element to edit. |
- Returns
- A pair of a reference to the element and a mutex ownership wrapper.
◆ edit()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Provides a way to edit an element exclusively. If no element exists with an equivalent key, this container creates a new element with key.
- Parameters
-
key | A key of the element to edit. |
editor | A function object which edits an element. |
◆ cbegin()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Returns an iterator to the first element of the map. If the container is empty, the returned iterator will be equal to end().
- Returns
- A const iterator to the first element.
◆ cend()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Returns an iterator to the element following the last element of the map. This element acts as a placeholder; attempting to access it results in undefined behavior.
- Returns
- A const iterator to the element following the last element.
◆ find()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Finds an element with an equivalent key.
- Parameters
-
key | A key value of the element to search for |
- Returns
- An iterator to an element with an equivalent key. If no such element is found, the returned iterator will be equal to end().
◆ get_allocator()
template<typename _key_type , typename _mapped_type , typename _compare = std::less<_key_type>, typename _bank_no_hasher = std::hash<_key_type>, typename _allocator = std::allocator<std::pair<const _key_type, _mapped_type>>, int k_num_banks = 1024>
Returns the allocator associated with the container.
- Returns
- An object of the associated allocator.
The documentation for this class was generated from the following file: