13#ifndef CXXUTILS_CONCURRENTMAP_H
14#define CXXUTILS_CONCURRENTMAP_H
22#include "boost/iterator/iterator_facade.hpp"
89template <
class KEY,
class VALUE,
template <
class>
class UPDATER,
90 class HASHER = std::hash<KEY>,
91 class MATCHER = std::equal_to<KEY>,
144 static_assert(
sizeof(
typename Impl_t::val_t) >=
sizeof(
key_type) );
145 static_assert(
sizeof(
typename Impl_t::val_t) >=
sizeof(
mapped_type) );
158 const Context_t& ctx = Updater_t::defaultContext());
173 const Context_t& ctx = Updater_t::defaultContext());
188 template <
class InputIterator>
193 const Context_t& ctx = Updater_t::defaultContext());
249 :
public boost::iterator_facade<const_iterator,
250 const const_iterator_value,
251 std::bidirectional_iterator_tag,
252 const const_iterator_value>
272 friend class boost::iterator_core_access;
323 const_iterator
end()
const;
380 std::pair<const_iterator, const_iterator>
406 std::pair<const_iterator, bool>
408 const Context_t& ctx = Updater_t::defaultContext());
423 std::pair<const_iterator, bool>
426 const Context_t& ctx = Updater_t::defaultContext());
440 std::pair<const_iterator, bool>
442 const Context_t& ctx = Updater_t::defaultContext());
458 std::pair<const_iterator, bool>
461 const Context_t& ctx = Updater_t::defaultContext());
477 template <
class PAIR>
478 std::pair<const_iterator, bool>
insert (
const PAIR& p);
489 template <
class InputIterator>
490 void insert (InputIterator first, InputIterator last);
533 const Context_t& ctx = Updater_t::defaultContext());
552 const Context_t& ctx = Updater_t::defaultContext());
651 std::pair<const_iterator, bool>
654 bool overwrite =
true,
655 const Context_t& ctx = Updater_t::defaultContext());
670 std::pair<const_iterator, bool>
674 bool overwrite =
true,
675 const Context_t& ctx = Updater_t::defaultContext());
Hash table allowing concurrent, lockless reads.
Concept check for Updater class used by concurrent classes.
Helpers for converting between uintptr_t and a pointer or integer.
bool valid() const
Test if this iterator is valid.
const_iterator(typename Impl_t::const_iterator it)
Constructor.
void increment()
iterator_facade requirement: Increment the iterator.
const const_iterator_value dereference() const
iterator_facade requirement: Dereference the iterator.
void decrement()
iterator_facade requirement: Decrement the iterator.
bool equal(const const_iterator &other) const
iterator_facade requirement: Equality test.
Impl_t::const_iterator m_impl
The iterator on the underlying table.
bool contains(key_type key) const
const_iterator find(key_type key) const
size_type count(key_type key) const
const_iterator cbegin() const
Impl_t::const_iterator get(key_type key) const
void clear(const Context_t &ctx=Updater_t::defaultContext())
void quiescent(const Context_t &ctx)
std::pair< const_iterator, bool > insert_or_assign(const Lock_t &lock, key_type key, mapped_type val, const Context_t &ctx=Updater_t::defaultContext())
const_iterator_range range() const
ConcurrentMap(const ConcurrentMap &other)=delete
void reserve(size_type capacity, const Context_t &ctx=Updater_t::defaultContext())
std::pair< const_iterator, bool > insert(const PAIR &p)
ConcurrentMap(InputIterator f, InputIterator l, Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
static val_t keyAsVal(key_type k)
static val_t mappedAsVal(mapped_type val)
bool erase(const Lock_t &lock, key_type key)
typename detail::ConcurrentHashmapImpl< UPDATER, Hasher, Matcher, NULLVAL, TOMBSTONE > Impl_t
The underlying uint->uint hash table.
std::pair< const key_type, mapped_type > const_iterator_value
Value structure for iterators.
static key_type keyAsKey(val_t val)
Convert an underlying key value to this type's key value.
std::pair< const_iterator, bool > put(const Lock_t &lock, key_type key, mapped_type val, bool overwrite=true, const Context_t &ctx=Updater_t::defaultContext())
std::pair< const_iterator, bool > emplace(key_type key, mapped_type val, const Context_t &ctx=Updater_t::defaultContext())
mapped_type at(key_type key) const
typename Impl_t::Updater_t Updater_t
Updater object.
void clear(size_t capacity, const Context_t &ctx=Updater_t::defaultContext())
ConcurrentMap(Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Ensure that the underlying map can store our types.
CxxUtils::detail::ConcurrentHashmapVal_t val_t
Representation type in the underlying map.
std::pair< const_iterator, bool > insert_or_assign(key_type key, mapped_type val, const Context_t &ctx=Updater_t::defaultContext())
ConcurrentMap(const ConcurrentMap &other, Updater_t &&updater, size_t capacity=64, const Context_t &ctx=Updater_t::defaultContext())
std::pair< const_iterator, bool > put(key_type key, mapped_type val, bool overwrite=true, const Context_t &ctx=Updater_t::defaultContext())
ConcurrentMap(ConcurrentMap &&other)=delete
const_iterator cend() const
const_iterator end() const
void swap(ConcurrentMap &other)
KEY key_type
Standard STL types.
const_iterator begin() const
void insert(InputIterator first, InputIterator last)
CxxUtils::iterator_range< const_iterator > const_iterator_range
A range defined by two iterators.
std::pair< const_iterator, const_iterator > equal_range(key_type key) const
static mapped_type mappedAsMapped(val_t val)
void rehash(size_type capacity)
typename Impl_t::Lock_t Lock_t
Type for external locking.
std::pair< const_iterator, bool > emplace(const Lock_t &lock, key_type key, mapped_type val, const Context_t &ctx=Updater_t::defaultContext())
typename Updater_t::Context_t Context_t
Context type.
Hash table allowing concurrent, lockless reads.
Simple range from a pair of iterators.
Concept for a value that can be saved in a concurrent hash map.
Concept check for Updater class used by concurrent classes.
A couple standard-library related concepts.
Simple range from a pair of iterators.
uintptr_t ConcurrentHashmapVal_t
Type used for keys and values — an unsigned big enough to hold a pointer.