PMDK C++ bindings  1.11
This is the C++ bindings documentation for PMDK's libpmemobj.
Public Member Functions | List of all members
pmem::obj::experimental::concurrent_map< Key, Value, Comp, Allocator > Class Template Reference

Persistent memory aware implementation of Intel TBB concurrent_map. More...

#include <libpmemobj++/experimental/concurrent_map.hpp>

Inheritance diagram for pmem::obj::experimental::concurrent_map< Key, Value, Comp, Allocator >:
Inheritance graph
[legend]
Collaboration diagram for pmem::obj::experimental::concurrent_map< Key, Value, Comp, Allocator >:
Collaboration graph
[legend]

Public Member Functions

 concurrent_map ()=default
 Default constructor.
 
 concurrent_map (const concurrent_map &table)
 Copy constructor.
 
 concurrent_map (concurrent_map &&table)
 Move constructor.
 
 concurrent_map (const key_compare &comp, const allocator_type &alloc=allocator_type())
 Construct the empty map.
 
template<class InputIt >
 concurrent_map (InputIt first, InputIt last, const key_compare &comp=Comp(), const allocator_type &alloc=allocator_type())
 Constructs the map with the contents of the range [first, last).
 
 concurrent_map (std::initializer_list< value_type > ilist)
 Constructs the map with initializer list.
 
concurrent_mapoperator= (const concurrent_map &other)
 Assignment operator.
 
concurrent_mapoperator= (concurrent_map &&other)
 Move-assignment operator.
 
- Public Member Functions inherited from pmem::detail::concurrent_skip_list< detail::map_traits< Key, Value, Comp, detail::default_random_generator, Allocator, false, 64 > >
 concurrent_skip_list ()
 Default constructor. More...
 
 concurrent_skip_list (const key_compare &comp, const allocator_type &alloc=allocator_type())
 Constructs an empty container. More...
 
 concurrent_skip_list (InputIt first, InputIt last, const key_compare &comp=key_compare(), const allocator_type &alloc=allocator_type())
 Constructs the container with the contents of the range [first, last). More...
 
 concurrent_skip_list (const concurrent_skip_list &other)
 Copy constructor. More...
 
 concurrent_skip_list (const concurrent_skip_list &other, const allocator_type &alloc)
 Copy constructor. More...
 
 concurrent_skip_list (concurrent_skip_list &&other)
 Move constructor. More...
 
 concurrent_skip_list (concurrent_skip_list &&other, const allocator_type &alloc)
 Move constructor. More...
 
void runtime_initialize ()
 Intialize concurrent_skip_list after process restart. More...
 
void free_data ()
 Should be called before concurrent_skip_list destructor is called. More...
 
 ~concurrent_skip_list ()
 Destructor. More...
 
concurrent_skip_listoperator= (const concurrent_skip_list &other)
 Copy assignment operator. More...
 
concurrent_skip_listoperator= (concurrent_skip_list &&other)
 Move assignment operator. More...
 
concurrent_skip_listoperator= (std::initializer_list< value_type > il)
 Replaces the contents with those identified by initializer list il. More...
 
std::pair< iterator, bool > insert (const value_type &value)
 Inserts value in a thread-safe way. More...
 
std::pair< iterator, bool > insert (P &&value)
 Inserts value. More...
 
std::pair< iterator, bool > insert (value_type &&value)
 Inserts value using move semantic. More...
 
iterator insert (const_iterator hint, const_reference value)
 Inserts value in the position as close as possible, just prior to hint. More...
 
iterator insert (const_iterator hint, P &&value)
 Inserts value in the position as close as possible, just prior to hint. More...
 
void insert (InputIterator first, InputIterator last)
 Inserts elements from range [first, last). More...
 
void insert (std::initializer_list< value_type > ilist)
 Inserts elements from initializer list ilist. More...
 
std::pair< iterator, bool > emplace (Args &&... args)
 Inserts a new element into the container constructed in-place with the given args if there is no element with the key in the container. More...
 
iterator emplace_hint (const_iterator hint, Args &&... args)
 Inserts a new element to the container as close as possible to the position just before hint. More...
 
std::pair< iterator, bool > try_emplace (const key_type &k, Args &&... args)
 If a key equivalent to k already exists in the container, does nothing. More...
 
std::pair< iterator, bool > try_emplace (key_type &&k, Args &&... args)
 If a key equivalent to k already exists in the container, does nothing. More...
 
std::enable_if< has_is_transparent< key_compare >::value &&std::is_constructible< key_type, K &&>::value, std::pair< iterator, bool > >::type try_emplace (K &&k, Args &&... args)
 If a key equivalent to k already exists in the container, does nothing. More...
 
iterator unsafe_erase (iterator pos)
 Removes the element at pos from the container. More...
 
iterator unsafe_erase (const_iterator pos)
 Removes the element at pos from the container. More...
 
iterator unsafe_erase (const_iterator first, const_iterator last)
 Removes the elements in the range [first; last), which must be a valid range in *this. More...
 
size_type unsafe_erase (const key_type &key)
 Removes the element (if one exists) with the key equivalent to key. More...
 
size_type unsafe_erase (const K &key)
 Removes the element (if one exists) with the key equivalent to key. More...
 
iterator lower_bound (const key_type &key)
 Returns an iterator pointing to the first element that is not less than (i.e. More...
 
const_iterator lower_bound (const key_type &key) const
 Returns an iterator pointing to the first element that is not less than (i.e. More...
 
iterator lower_bound (const K &x)
 Returns an iterator pointing to the first element that compares not less (i.e. More...
 
const_iterator lower_bound (const K &x) const
 Returns an iterator pointing to the first element that compares not less (i.e. More...
 
iterator find_higher_eq (const key_type &key)
 Returns an iterator pointing to the first element that is not less than (i.e. More...
 
const_iterator find_higher_eq (const key_type &key) const
 Returns an iterator pointing to the first element that is not less than (i.e. More...
 
iterator find_higher_eq (const K &x)
 Returns an iterator pointing to the first element that compares not less (i.e. More...
 
const_iterator find_higher_eq (const K &x) const
 Returns an iterator pointing to the first element that compares not less (i.e. More...
 
iterator upper_bound (const key_type &key)
 Returns an iterator pointing to the first element that is greater than key. More...
 
const_iterator upper_bound (const key_type &key) const
 Returns an iterator pointing to the first element that is greater than key. More...
 
iterator upper_bound (const K &x)
 Returns an iterator pointing to the first element that compares greater to the value x. More...
 
const_iterator upper_bound (const K &x) const
 Returns an iterator pointing to the first element that compares greater to the value x. More...
 
iterator find_higher (const key_type &key)
 Returns an iterator pointing to the first element that is greater than key. More...
 
const_iterator find_higher (const key_type &key) const
 Returns an iterator pointing to the first element that is greater than key. More...
 
iterator find_higher (const K &x)
 Returns an iterator pointing to the first element that compares greater to the value x. More...
 
const_iterator find_higher (const K &x) const
 Returns an iterator pointing to the first element that compares greater to the value x. More...
 
iterator find_lower (const key_type &key)
 Returns an iterator pointing to the biggest element that is less than key. More...
 
const_iterator find_lower (const key_type &key) const
 Returns a const iterator pointing to the biggest element that is less than key. More...
 
iterator find_lower (const K &key)
 Returns an iterator pointing to the biggest element that is less than key. More...
 
const_iterator find_lower (const K &key) const
 Returns a const iterator pointing to the biggest element that is less than key. More...
 
iterator find_lower_eq (const key_type &key)
 Returns an iterator pointing to the biggest element that is less than or equal to key. More...
 
const_iterator find_lower_eq (const key_type &key) const
 Returns a const iterator pointing to the biggest element that is less than or equal to key. More...
 
iterator find_lower_eq (const K &key)
 Returns an iterator pointing to the biggest element that is less than or equal to key. More...
 
const_iterator find_lower_eq (const K &key) const
 Returns a const iterator pointing to the biggest element that is less than or equal to key. More...
 
iterator find (const key_type &key)
 Finds an element with key equivalent to key. More...
 
const_iterator find (const key_type &key) const
 Finds an element with key equivalent to key. More...
 
iterator find (const K &x)
 Finds an element with key that compares equivalent to the value x. More...
 
const_iterator find (const K &x) const
 Finds an element with key that compares equivalent to the value x. More...
 
size_type count (const key_type &key) const
 Returns the number of elements with key that compares equivalent to the specified argument. More...
 
size_type count (const K &key) const
 Returns the number of elements with key that compares equivalent to the specified argument. More...
 
bool contains (const key_type &key) const
 Checks if there is an element with key equivalent to key in the container. More...
 
bool contains (const K &x) const
 Checks if there is an element with key that compares equivalent to the value x. More...
 
void clear ()
 Erases all elements from the container transactionally. More...
 
iterator begin ()
 Returns an iterator to the first element of the container. More...
 
const_iterator begin () const
 Returns an iterator to the first element of the container. More...
 
const_iterator cbegin () const
 Returns an iterator to the first element of the container. More...
 
iterator end ()
 Returns an iterator to the element following the last element of the map. More...
 
const_iterator end () const
 Returns an iterator to the element following the last element of the map. More...
 
const_iterator cend () const
 Returns an iterator to the element following the last element of the map. More...
 
size_type size () const
 Returns the number of elements in the container, i.e. More...
 
size_type max_size () const
 Returns the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. More...
 
bool empty () const
 Checks if the container has no elements, i.e. More...
 
void swap (concurrent_skip_list &other)
 XXX: Implement get_allocator() interface. More...
 
std::pair< iterator, iterator > equal_range (const key_type &key)
 Returns a range containing all elements with the given key in the container. More...
 
std::pair< const_iterator, const_iterator > equal_range (const key_type &key) const
 Returns a range containing all elements with the given key in the container. More...
 
std::pair< iterator, iterator > equal_range (const K &x)
 Returns a range containing all elements with the given key in the container. More...
 
std::pair< const_iterator, const_iterator > equal_range (const K &key) const
 Returns a range containing all elements with the given key in the container. More...
 
const key_compare & key_comp () const
 Returns a const reference to the object that compares the keys. More...
 
key_compare & key_comp ()
 Returns a reference to the object that compares the keys. More...
 

Detailed Description

template<typename Key, typename Value, typename Comp = std::less<Key>, typename Allocator = pmem::obj::allocator<detail::pair<const Key, Value>>>
class pmem::obj::experimental::concurrent_map< Key, Value, Comp, Allocator >

Persistent memory aware implementation of Intel TBB concurrent_map.

It is a sorted associative container that contains key-value pairs with unique keys. Keys are sorted by using the comparison function Compare. Search, removal, and insertion operations have average logarithmic complexity. Everywhere the concurrent_map uses the Compare requirements, uniqueness is determined by using the equivalence relation. In imprecise terms, two objects a and b are considered equivalent (not unique) if neither compares less than the other: !comp(a, b) && !comp(b, a).

The implementation is based on the lock-based concurrent skip list algorithm described in https://www.cs.tau.ac.il/~shanir/nir-pubs-web/Papers/OPODIS2006-BA.pdf. Our concurrent skip list implementation supports concurrent insertion and traversal, but not concurrent erasure. The erase method is prefixed with unsafe_, to indicate that there is no concurrency safety.

Each time, the pool with concurrent_map is being opened, the concurrent_map requires runtime_initialize() to be called in order to restore the map state after process restart.

Key, Value, Comp and Allcoator types should be persistent memory aware types. Allocator type should satisfies the named requirements (https://en.cppreference.com/w/cpp/named_req/Allocator). The allocate() and deallocate() methods are called inside transactions.


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