|
ATLAS Offline Software
|
Go to the documentation of this file.
16 #ifndef CXXUTILS_CONCURRENTBITSET_H
17 #define CXXUTILS_CONCURRENTBITSET_H
31 #include <type_traits>
164 static_assert (std::atomic<Block_t>::is_always_lock_free);
532 template <
class ITERATOR,
533 typename =
typename std::enable_if<
535 typename std::forward_iterator_tag,
536 typename std::iterator_traits<ITERATOR>::iterator_category
717 const std::atomic<Block_t>*
data,
718 const std::atomic<Block_t>*
end);
853 void*
operator new (
size_t ,
bit_t nbits);
860 void operator delete (
void*
p);
916 #if defined(__x86_64__) && HAVE_FUNCTION_MULTIVERSIONING
1086 #endif // not CXXUTILS_CONCURRENTBITSET_H
ConcurrentBitset & set(bit_t bit)
Turn on one bit.
char data[hepevt_bytes_allocation_ATLAS]
Some additional feature test macros.
size_t count(bit_t bit) const
Test to see if a bit is set.
size_t m_nblocks
Number of blocks in the container.
std::mutex mutex_t
Mutex used for synchronization when switching to a new implementation object.
ConcurrentBitset & flip(bit_t bit)
Flip the value of one bit.
ptrdiff_t difference_type
const value_type * pointer
bool all() const
Return true if all bits in the set are 1.
bit_t count() const
Count the number of 1 bits in the set.
void clear()
Clear all bits in the set.
Variable-sized bitset allowing (mostly) concurrent access.
const_iterator & operator++()
Advance the iterator to the next set bit (preincrement).
std::atomic< Block_t > * block(bit_t bit)
Return a pointer to the block containing bit.
const_iterator operator++(int)
Advance the iterator to the next set bit (postincrement).
unsigned long Block_t
Internal type used to hold the bitset data.
const_iterator end() const
Return an end iterator.
bit_t capacity() const
The number of bits that this container can hold.
size_t bit_t
A bit number.
ConcurrentBitset & operator&=(const ConcurrentBitset &other)
AND this set with another set.
ConcurrentBitset operator~() const
Return a new set that is the complement of this set.
ConcurrentBitset & operator^=(const ConcurrentBitset &other)
XOR this set with another set.
Iterator over all 1 bits in the set.
Block_t m_mask
Mask of the referenced bit within the block.
const_iterator(Block_t cache, bit_t bit, const std::atomic< Block_t > *data, const std::atomic< Block_t > *end)
Constructor.
void operate(operator_t op, const Impl &other)
Apply a binary operation.
std::atomic< Impl * > m_impl
The current implementation object.
bool const RAWDATA *ch2 const
const_iterator find(bit_t bit) const
If bit bit is set, return an iterator pointing to it.
ConcurrentBitset & reset()
Clear all bits in the set.
const value_type & reference
Atomic min/max functions.
ConcurrentBitset & insert(ITERATOR beg, ITERATOR end, bit_t new_nbits=0)
Set several bits to 1.
void set(bit_t bit)
Turn on one bit.
ConcurrentBitset & clear()
Clear all bits in the set.
ConcurrentBitset(bit_t nbits=0)
Constructor.
Impl(const Impl &other, bit_t nbits=0)
Copy constructor.
ConcurrentBitset & operator-=(const ConcurrentBitset &other)
Subtract another set from this set.
reference(Impl &impl, bit_t bit)
Constructor.
std::forward_iterator_tag iterator_category
ConcurrentBitset & operator|=(const ConcurrentBitset &other)
OR this set with another set.
A reference to one bit in a set.
void expandOol(bit_t new_nbits)
Expand the container: out-of-line portion.
bit_t size() const
Count the number of 1 bits in the set.
std::lock_guard< mutex_t > lock_t
ConcurrentBitset & insert(std::initializer_list< bit_t > l, bit_t new_nbits=0)
Set several bits to 1.
reference & operator=(bool val) noexcept
Set the referenced bit to a given value.
std::atomic< Block_t > * m_block
Pointer to the block containing the referenced bit.
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
const_iterator begin() const
Return an iterator referencing the first 1 bit.
bool operator!=(const ConcurrentBitset &other) const
Test two sets for inequality.
ConcurrentBitset & reset(bit_t bit)
Turn off one bit.
const_iterator end() const
Return the end iterator.
bool empty() const
Return true if there are no 1 bits in the set.
static const size_t MASK
Mask to select out the bit offset within one Block_t.
size_t m_nbits
Number of bits in the container.
~ConcurrentBitset()
Destructor.
ConcurrentBitset & set(bit_t bit, bool val)
Set the value of one bit.
const_iterator find(bit_t bit) const
If bit bit is set, return an iterator pointing to it.
bool any() const
Return true if there are any 1 bits in the set.
ConcurrentBitset & insert(const ConcurrentBitset &other)
Turn on bits listed in another set.
void assign(const Impl &other)
Copy from another instance.
const_iterator begin() const
Return a begin iterator.
void reset(bit_t bit)
Turn off one bit.
static const size_t BLOCKSIZE
Size, in bits, of Block_t.
const std::atomic< Block_t > * m_data
Pointer to the block containing the bit which we're currently referencing.
const std::atomic< Block_t > * m_end
Pointer to one past the last block in the set.
bool none() const
Return true if there are no 1 bits in the set.
std::atomic< size_t > m_hwm
High-water mark: index of last block with a 1 bit.
void expand(bit_t new_nbits)
Expand the container.
bit_t nbits() const
Return the number of bits in the set.
std::vector< Impl * > m_garbage
Old implementation objects, pending deletion.
bit_t m_bit
Bit number which we're currently referencing.
bool test(bit_t bit) const
Test to see if a bit is set.
ConcurrentBitset & set()
Turn on all bits in the set.
ConcurrentBitset & flip()
Flip the state of all bits in the set.
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
void flip(bit_t bit)
Flip the value of one bit.
ConcurrentBitset & operator=(const ConcurrentBitset &other)
Assignment.
void operator_t(std::atomic< Block_t > &a, Block_t v)
Impl * newImpl(bit_t nbits)
Create a new, uninitialized implementation object.
Block_t m_cache
Cache of the block to which we're currently pointing.
void emptyGarbage()
Clean up old versions of the set.
bool operator==(const ConcurrentBitset &other) const
Test two sets for equality.
ConcurrentBitset & erase(bit_t bit)
Turn off one bit.
reference & flip() noexcept
Invert the referenced bit.
setBGCode setTAP setLVL2ErrorBits bool
static bit_t nBlocks(bit_t nbits)
Find number of blocks needed to hold a given number of bits.
bit_t operator*() const
Return the bit number which the iterator is currently referencing.
Impl(bit_t nbits)
Constructor.
bool test(bit_t bit) const
Test to see if a bit is set.