16#include "boost/iterator/iterator_facade.hpp"
21#ifndef CXXUTILS_CONCURRENTPTRSET_H
22#define CXXUTILS_CONCURRENTPTRSET_H
74template <
class VALUE,
template <
class>
class UPDATER>
97 using Lock_t =
typename Impl_t::Lock_t;
110 const Context_t& ctx = Updater_t::defaultContext());
126 const Context_t& ctx = Updater_t::defaultContext());
139 template <
class InputIterator>
144 const Context_t& ctx = Updater_t::defaultContext());
194 :
public boost::iterator_facade<const_iterator,
195 const const_iterator_value,
196 std::bidirectional_iterator_tag,
197 const const_iterator_value>
217 friend class boost::iterator_core_access;
268 const_iterator
end()
const;
315 std::pair<const_iterator, const_iterator>
340 std::pair<const_iterator, bool>
342 const Context_t& ctx = Updater_t::defaultContext());
356 std::pair<const_iterator, bool>
359 const Context_t& ctx = Updater_t::defaultContext());
381 template <
class InputIterator>
382 void insert (InputIterator first, InputIterator last);
394 const Context_t& ctx = Updater_t::defaultContext());
413 const Context_t& ctx = Updater_t::defaultContext());
484 std::pair<const_iterator, bool>
486 const Context_t& ctx = Updater_t::defaultContext());
499 std::pair<const_iterator, bool>
502 const Context_t& ctx = Updater_t::defaultContext());
514 size_t operator() (
const val_t p)
const;
Hash table allowing concurrent, lockless reads.
Concept check for Updater class used by concurrent classes.
bool equal(const const_iterator &other) const
iterator_facade requirement: Equality test.
Impl_t::const_iterator m_impl
The iterator on the underlying table.
key_type dereference() const
iterator_facade requirement: Dereference the iterator.
bool valid() const
Test if this iterator is valid.
void decrement()
iterator_facade requirement: Decrement the iterator.
const_iterator(typename Impl_t::const_iterator it)
Constructor.
void increment()
iterator_facade requirement: Increment the iterator.
const CondContBase * const_key_type
CxxUtils::detail::ConcurrentHashmapVal_t val_t
std::pair< const_iterator, bool > put(const key_type key, const Context_t &ctx=Updater_t::defaultContext())
Insert an entry in the table.
size_type count(const const_key_type key) const
Return the number of times a given key is in the container.
ConcurrentPtrSet(const ConcurrentPtrSet &other)=delete
Copy / move / assign not supported.
std::pair< const_iterator, const_iterator > equal_range(const const_key_type key) const
Return a range of iterators with entries matching key.
std::pair< const_iterator, bool > emplace(const Lock_t &lock, const key_type key, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the set, with external locking.
void swap(ConcurrentPtrSet &other)
Swap this container with another.
Lock_t lock()
Take a lock on the container.
const key_type const_iterator_value
CxxUtils::iterator_range< const_iterator > const_iterator_range
ConcurrentPtrSet(const ConcurrentPtrSet &other, Updater_t &&updater, size_t capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Constructor from another set.
const_iterator cbegin() const
Iterator at the start of the set.
const_iterator find(const const_key_type key) const
Look up an element in the set.
size_type size() const
Return the number of items currently in the set.
void reserve(size_type capacity, const Context_t &ctx=Updater_t::defaultContext())
Increase the table capacity.
std::pair< const_iterator, bool > put(const Lock_t &lock, const key_type key, const Context_t &ctx=Updater_t::defaultContext())
Insert an entry in the table, with external locking.
const_iterator end() const
Iterator at the end of the set.
typename Impl_t::Updater_t Updater_t
ConcurrentPtrSet(ConcurrentPtrSet &&other)=delete
typename detail::ConcurrentHashmapImpl< CxxUtils::SimpleUpdater, Hasher, Matcher > Impl_t
void rehash(size_type capacity)
Increase the table capacity.
static val_t keyAsVal(const const_key_type p)
Convert a pointer to an underlying key value.
bool contains(const const_key_type key) const
Test if a key is in the container.
Impl_t::const_iterator get(const const_key_type key) const
Do a lookup in the table.
bool empty() const
Test if the set is currently empty.
void clear(const Context_t &ctx=Updater_t::defaultContext())
Erase the table (don't change the capacity).
ConcurrentPtrSet(Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Constructor.
const_iterator_range range() const
Return an iterator range covering the entire set.
~ConcurrentPtrSet()
Destructor.
std::pair< const_iterator, bool > insert(const key_type p)
Add an element to the set.
std::pair< const_iterator, bool > emplace(const key_type key, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the set.
ConcurrentPtrSet(InputIterator f, InputIterator l, Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Constructor from a range.
void quiescent(const Context_t &ctx)
Called when this thread is no longer referencing anything from this container.
typename Updater_t::Context_t Context_t
typename Impl_t::Lock_t Lock_t
const_iterator cend() const
Iterator at the end of the set.
const_iterator begin() const
Iterator at the start of the set.
void insert(InputIterator first, InputIterator last)
Insert a range of elements to the set.
void clear(size_t capacity, const Context_t &ctx=Updater_t::defaultContext())
Erase the table and change the capacity.
static key_type keyAsPtr(val_t val)
Convert an underlying key value to a pointer.
Hash table allowing concurrent, lockless reads.
Simple range from a pair of iterators.
Concept check for Updater class used by concurrent classes.
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.
Hash functional for keys.
std::hash< const_key_type > m_hash
Hash functional.
Matching functional for keys.