|
ATLAS Offline Software
|
Go to the documentation of this file.
16 #include "boost/iterator/iterator_facade.hpp"
17 #include "boost/range/iterator_range.hpp"
18 #include <type_traits>
21 #ifndef CXXUTILS_CONCURRENTPTRSET_H
22 #define CXXUTILS_CONCURRENTPTRSET_H
74 template <
class VALUE,
template <
class>
class UPDATER>
97 using Lock_t =
typename Impl_t::Lock_t;
110 const Context_t& ctx = Updater_t::defaultContext());
125 size_t capacity = 64,
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>
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());
543 #endif // not CXXUTILS_CONCURRENTPTRSET_H
const_iterator find(const const_key_type key) const
Look up an element in the set.
Matching functional for keys.
void decrement()
iterator_facade requirement: Decrement the iterator.
std::hash< const_key_type > m_hash
Hash functional.
ConcurrentPtrSet(Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Constructor.
const_iterator(typename Impl_t::const_iterator it)
Constructor.
uintptr_t ConcurrentHashmapVal_t
Type used for keys and values — an unsigned big enough to hold a pointer.
typename detail::ConcurrentHashmapImpl< CxxUtils::SimpleUpdater, Hasher, Matcher > Impl_t
bool equal(const const_iterator &other) const
iterator_facade requirement: Equality test.
size_type count(const const_key_type key) const
Return the number of times a given key is in the container.
Concept check for Updater class used by concurrent classes.
CxxUtils::detail::ConcurrentHashmapVal_t val_t
Representation type in the underlying map.
size_type size() const
Return the number of items currently in the set.
VALUE * key_type
Standard STL types.
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.
size_t capacity() const
Return the current size (capacity) of the hash table.
typename Impl_t::Lock_t Lock_t
Type for external locking.
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_range range() const
Return an iterator range covering the entire set.
void clear(const Context_t &ctx=Updater_t::defaultContext())
Erase the table (don't change the capacity).
void reserve(size_type capacity, const Context_t &ctx=Updater_t::defaultContext())
Increase the table capacity.
Updater_t & updater()
Access the Updater instance.
std::pair< const_iterator, bool > insert(const key_type p)
Add an element to the set.
typename Impl_t::Updater_t Updater_t
Updater object.
static key_type keyAsPtr(val_t val)
Convert an underlying key value to a pointer.
Base class for all conditions containers.
Lock_t lock()
Take a lock on the container.
const_iterator end() const
Iterator at the end of the set.
const_iterator cend() const
Iterator at the end of the set.
bool empty() const
Test if the set is currently empty.
ConcurrentPtrSet(const ConcurrentPtrSet &other)=delete
Copy / move / assign not supported.
bool valid() const
Test if this iterator is valid.
void swap(ConcurrentPtrSet &other)
Swap this container with another.
Impl_t::const_iterator get(const const_key_type key) const
Do a lookup in the table.
void increment()
iterator_facade requirement: Increment the iterator.
const_iterator begin() const
Iterator at the start of the set.
bool contains(const const_key_type key) const
Test if a key is in the container.
std::pair< const_iterator, bool > put(const key_type key, const Context_t &ctx=Updater_t::defaultContext())
Insert an entry in the table.
static val_t keyAsVal(const const_key_type p)
Convert a pointer to an underlying key value.
key_type dereference() const
iterator_facade requirement: Dereference the iterator.
Impl_t::const_iterator m_impl
The iterator on the underlying table.
A set of pointers, allowing concurrent, lockless queries.
Hash functional for keys.
std::pair< const_iterator, bool > emplace(const key_type key, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the set.
Impl_t m_impl
The underlying hash table.
Compatibility helpers for using some pieces of C++20 concepts with older compilers.
typename Updater_t::Context_t Context_t
Context type.
std::pair< const_iterator, const_iterator > equal_range(const const_key_type key) const
Return a range of iterators with entries matching key.
void insert(InputIterator first, InputIterator last)
Insert a range of elements to the set.
~ConcurrentPtrSet()
Destructor.
ATH_REQUIRES(detail::IsConcurrentHashmapPayload< KEY > &&detail::IsConcurrentHashmapPayload< VALUE > &&detail::IsUpdater< UPDATER > &&detail::IsHash< HASHER, KEY > &&detail::IsBinaryPredicate< MATCHER, KEY >) class ConcurrentMap
Hash map from integers/pointers allowing concurrent, lockless reads.
void clear(size_t capacity, const Context_t &ctx=Updater_t::defaultContext())
Erase the table and change the capacity.
const VALUE * const_key_type
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 rehash(size_type capacity)
Increase the table capacity.
void quiescent(const Context_t &ctx)
Called when this thread is no longer referencing anything from this container.
boost::iterator_range< const_iterator > const_iterator_range
A range defined by two iterators.
ConcurrentPtrSet(InputIterator f, InputIterator l, Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Constructor from a range.
ConcurrentPtrSet(ConcurrentPtrSet &&other)=delete
Hash table allowing concurrent, lockless reads.