ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Static Private Attributes | List of all members
SG::auxid_set_t Class Reference

A set of aux data identifiers. More...

#include <AuxTypes.h>

Inheritance diagram for SG::auxid_set_t:
Collaboration diagram for SG::auxid_set_t:

Public Types

typedef size_t bit_t
 A bit number. More...
 

Public Member Functions

 auxid_set_t (size_t nbits=auxid_set_size_hint)
 
Constructors, destructors, assignment.
void emptyGarbage ()
 Clean up old versions of the set. More...
 
Size, bit testing
bit_t capacity () const
 The number of bits that this container can hold. More...
 
bit_t count () const
 Count the number of 1 bits in the set. More...
 
size_t count (bit_t bit) const
 Test to see if a bit is set. More...
 
bit_t size () const
 Count the number of 1 bits in the set. More...
 
bool test (bit_t bit) const
 Test to see if a bit is set. More...
 
bool empty () const
 Return true if there are no 1 bits in the set. More...
 
bool none () const
 Return true if there are no 1 bits in the set. More...
 
bool all () const
 Return true if all bits in the set are 1. More...
 
bool any () const
 Return true if there are any 1 bits in the set. More...
 
Single-bit manipulation.
ConcurrentBitsetset (bit_t bit)
 Turn on one bit. More...
 
ConcurrentBitsetset (bit_t bit, bool val)
 Set the value of one bit. More...
 
ConcurrentBitsetreset (bit_t bit)
 Turn off one bit. More...
 
ConcurrentBitseterase (bit_t bit)
 Turn off one bit. More...
 
ConcurrentBitsetflip (bit_t bit)
 Flip the value of one bit. More...
 
Set operations.
ConcurrentBitsetset ()
 Turn on all bits in the set. More...
 
ConcurrentBitsetreset ()
 Clear all bits in the set. More...
 
ConcurrentBitsetflip ()
 Flip the state of all bits in the set. More...
 
ConcurrentBitsetclear ()
 Clear all bits in the set. More...
 
ConcurrentBitsetoperator&= (const ConcurrentBitset &other)
 AND this set with another set. More...
 
ConcurrentBitsetoperator|= (const ConcurrentBitset &other)
 OR this set with another set. More...
 
ConcurrentBitsetoperator^= (const ConcurrentBitset &other)
 XOR this set with another set. More...
 
ConcurrentBitsetoperator-= (const ConcurrentBitset &other)
 Subtract another set from this set. More...
 
ConcurrentBitset operator~ () const
 Return a new set that is the complement of this set. More...
 
Comparison.
bool operator== (const ConcurrentBitset &other) const
 Test two sets for equality. More...
 
bool operator!= (const ConcurrentBitset &other) const
 Test two sets for inequality. More...
 
Insert.
ConcurrentBitsetinsert (bit_t bit, bit_t new_nbits=0)
 Set a bit to 1. More...
 
template<class ITERATOR , typename = typename std::enable_if< std::is_base_of< typename std::forward_iterator_tag, typename std::iterator_traits<ITERATOR>::iterator_category >::value>>
ConcurrentBitsetinsert (ITERATOR beg, ITERATOR end, bit_t new_nbits=0)
 Set several bits to 1. More...
 
ConcurrentBitsetinsert (std::initializer_list< bit_t > l, bit_t new_nbits=0)
 Set several bits to 1. More...
 
ConcurrentBitsetinsert (const ConcurrentBitset &other)
 Turn on bits listed in another set. More...
 
Array-like element access.
bool operator[] (bit_t bit) const
 Return the value of one bit. More...
 
reference operator[] (bit_t bit)
 Return a reference to one bit. More...
 
Iterator operations.
const_iterator begin () const
 Return a begin iterator. More...
 
const_iterator end () const
 Return an end iterator. More...
 
const_iterator find (bit_t bit) const
 If bit bit is set, return an iterator pointing to it. More...
 
Size, bit testing
bit_t capacity () const
 The number of bits that this container can hold. More...
 
bit_t count () const
 Count the number of 1 bits in the set. More...
 
bit_t size () const
 Count the number of 1 bits in the set. More...
 
bool test (bit_t bit) const
 Test to see if a bit is set. More...
 
size_t count (bit_t bit) const
 Test to see if a bit is set. More...
 
bool empty () const
 Return true if there are no 1 bits in the set. More...
 
bool none () const
 Return true if there are no 1 bits in the set. More...
 
bool all () const
 Return true if all bits in the set are 1. More...
 
bool any () const
 Return true if there are any 1 bits in the set. More...
 
Single-bit manipulation.
ConcurrentBitsetset (bit_t bit)
 Turn on one bit. More...
 
ConcurrentBitsetreset (bit_t bit)
 Turn off one bit. More...
 
ConcurrentBitseterase (bit_t bit)
 Turn off one bit. More...
 
ConcurrentBitsetflip (bit_t bit)
 Flip the value of one bit. More...
 
ConcurrentBitsetset (bit_t bit, bool val)
 Set the value of one bit. More...
 
Set operations.
ConcurrentBitsetclear ()
 Clear all bits in the set. More...
 
ConcurrentBitsetreset ()
 Clear all bits in the set. More...
 
ConcurrentBitsetset ()
 Turn on all bits in the set. More...
 
ConcurrentBitsetflip ()
 Flip the state of all bits in the set. More...
 
ConcurrentBitsetoperator&= (const ConcurrentBitset &other)
 AND this set with another set. More...
 
ConcurrentBitsetoperator|= (const ConcurrentBitset &other)
 OR this set with another set. More...
 
ConcurrentBitsetoperator^= (const ConcurrentBitset &other)
 XOR this set with another set. More...
 
ConcurrentBitsetoperator-= (const ConcurrentBitset &other)
 Subtract another set from this set. More...
 
ConcurrentBitset operator~ () const
 Return a new set that is the complement of this set. More...
 
Comparison.
bool operator== (const ConcurrentBitset &other) const
 Test two sets for equality. More...
 
bool operator!= (const ConcurrentBitset &other) const
 Test two sets for inequality. More...
 
Insert.
ConcurrentBitsetinsert (bit_t bit, bit_t new_nbits=0)
 Set a bit to 1. More...
 
template<class ITERATOR , typename = typename std::enable_if< std::is_base_of< typename std::forward_iterator_tag, typename std::iterator_traits<ITERATOR>::iterator_category >::value>>
ConcurrentBitsetinsert (ITERATOR beg, ITERATOR end, bit_t new_nbits=0)
 Set several bits to 1. More...
 
ConcurrentBitsetinsert (std::initializer_list< bit_t > l, bit_t new_nbits=0)
 Set several bits to 1. More...
 
ConcurrentBitsetinsert (const ConcurrentBitset &other)
 Turn on bits listed in another set. More...
 
Array-like element access.
bool operator[] (bit_t bit) const
 Return the value of one bit. More...
 
reference operator[] (bit_t bit)
 Return a reference to one bit. More...
 
Iterator operations.
const_iterator begin () const
 Return a begin iterator. More...
 
const_iterator end () const
 Return an end iterator. More...
 
const_iterator find (bit_t bit) const
 If bit bit is set, return an iterator pointing to it. More...
 

Private Types

typedef unsigned long Block_t
 Internal type used to hold the bitset data. More...
 

Static Private Attributes

static const size_t BLOCKSIZE = sizeof(Block_t) * CHAR_BIT
 Size, in bits, of Block_t. More...
 
static const size_t MASK = BLOCKSIZE-1
 Mask to select out the bit offset within one Block_t. More...
 

Implementation.

typedef std::mutex mutex_t
 Mutex used for synchronization when switching to a new implementation object. More...
 
typedef std::lock_guard< mutex_tlock_t
 
std::atomic< Impl * > m_impl
 The current implementation object. More...
 
std::vector< Impl * > m_garbage
 Old implementation objects, pending deletion. More...
 
mutex_t m_mutex
 
static bit_t nBlocks (bit_t nbits)
 Find number of blocks needed to hold a given number of bits. More...
 
ImplnewImpl (bit_t nbits)
 Create a new, uninitialized implementation object. More...
 
void expand (bit_t new_nbits)
 Expand the container. More...
 
void expandOol (bit_t new_nbits)
 Expand the container: out-of-line portion. More...
 

Detailed Description

A set of aux data identifiers.

This is a ConcurrentBitset, with the default size set to auxid_set_size_hint.

Definition at line 45 of file AuxTypes.h.

Member Typedef Documentation

◆ bit_t

typedef size_t CxxUtils::ConcurrentBitset::bit_t
inherited

A bit number.

Definition at line 168 of file ConcurrentBitset.h.

◆ Block_t

typedef unsigned long CxxUtils::ConcurrentBitset::Block_t
privateinherited

Internal type used to hold the bitset data.

The bitset is an array of std::atomic<Block_t>. This type should generally be the largest unsigned type for which std::atomic is lockless.

Definition at line 155 of file ConcurrentBitset.h.

◆ lock_t

typedef std::lock_guard<mutex_t> CxxUtils::ConcurrentBitset::lock_t
privateinherited

Definition at line 1075 of file ConcurrentBitset.h.

◆ mutex_t

typedef std::mutex CxxUtils::ConcurrentBitset::mutex_t
privateinherited

Mutex used for synchronization when switching to a new implementation object.

Definition at line 1074 of file ConcurrentBitset.h.

Constructor & Destructor Documentation

◆ auxid_set_t()

SG::auxid_set_t::auxid_set_t ( size_t  nbits = auxid_set_size_hint)
inline

Definition at line 50 of file AuxTypes.h.

52  {
53  }

Member Function Documentation

◆ all()

bool CxxUtils::ConcurrentBitset::all ( ) const
inherited

Return true if all bits in the set are 1.

◆ any()

bool CxxUtils::ConcurrentBitset::any ( ) const
inherited

Return true if there are any 1 bits in the set.

◆ begin()

const_iterator CxxUtils::ConcurrentBitset::begin ( ) const
inherited

Return a begin iterator.

◆ capacity()

bit_t CxxUtils::ConcurrentBitset::capacity ( ) const
inherited

The number of bits that this container can hold.

◆ clear()

ConcurrentBitset& CxxUtils::ConcurrentBitset::clear ( )
inherited

Clear all bits in the set.

This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.

◆ count() [1/2]

bit_t CxxUtils::ConcurrentBitset::count ( ) const
inherited

Count the number of 1 bits in the set.

◆ count() [2/2]

size_t CxxUtils::ConcurrentBitset::count ( bit_t  bit) const
inherited

Test to see if a bit is set.

Parameters
bitNumber of the bit to test.
Returns
1 if the bit is set; 0 otherwise.

Returns 0 if bit is beyond the end of the set.

◆ empty()

bool CxxUtils::ConcurrentBitset::empty ( ) const
inherited

Return true if there are no 1 bits in the set.

◆ emptyGarbage()

void CxxUtils::ConcurrentBitset::emptyGarbage ( )
inherited

Clean up old versions of the set.

The insert and assignment operations may need to grow the set. The original version of the set is not deleted immediately, since other threads may still be accessing it. Call this when no other threads can be accessing old versions in order to clean them up.

Definition at line 148 of file ConcurrentBitset.cxx.

149 {
150  lock_t lock (m_mutex);
151  for (Impl* p : m_garbage) {
152  free (p);
153  }
154  m_garbage.clear();
155 }

◆ end()

const_iterator CxxUtils::ConcurrentBitset::end ( ) const
inherited

Return an end iterator.

◆ erase()

ConcurrentBitset& CxxUtils::ConcurrentBitset::erase ( bit_t  bit)
inherited

Turn off one bit.

Parameters
bitThe bit to turn off.

Does nothing if bit beyond the end of the set.

◆ expand()

void CxxUtils::ConcurrentBitset::expand ( bit_t  new_nbits)
privateinherited

Expand the container.

Parameters
new_nbitsThe desired new size of the container.

◆ expandOol()

void CxxUtils::ConcurrentBitset::expandOol ( bit_t  new_nbits)
privateinherited

Expand the container: out-of-line portion.

Parameters
new_nbitsThe desired new size of the container.

Definition at line 162 of file ConcurrentBitset.cxx.

163 {
164  // Need to take out the lock.
165  lock_t lock (m_mutex);
166  // Check the size again while we're holding the lock.
167  bit_t nbits = (*m_impl).nbits();
168  if (new_nbits > nbits) {
169  // We need to expand. Allocate a new implementation and initialize it,
170  // copying from the existing implementation.
171  Impl* i = new (new_nbits) Impl (*m_impl, new_nbits);
172 
173  // Remember that we need to delete the old object.
174  m_garbage.push_back (m_impl);
175 
176  // Publish the new one.
177  m_impl = i;
178  }
179 }

◆ find()

const_iterator CxxUtils::ConcurrentBitset::find ( bit_t  bit) const
inherited

If bit bit is set, return an iterator pointing to it.

Otherwise, return an end iterator.

Parameters
bitBit number to test.

◆ flip() [1/2]

ConcurrentBitset& CxxUtils::ConcurrentBitset::flip ( )
inherited

Flip the state of all bits in the set.

This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.

◆ flip() [2/2]

ConcurrentBitset& CxxUtils::ConcurrentBitset::flip ( bit_t  bit)
inherited

Flip the value of one bit.

Parameters
bitThe bit to turn flip.

Does nothing if bit beyond the end of the set.

◆ insert() [1/4]

ConcurrentBitset& CxxUtils::ConcurrentBitset::insert ( bit_t  bit,
bit_t  new_nbits = 0 
)
inherited

Set a bit to 1.

Expand the set if needed.

Parameters
bitNumber of the bit to set.
new_nbitsHint for new size of set, if it needs to be expanded.

If bit is past the end of the container, then the container will be expanded as needed.

This operation is incompatible with any other simultaneous writes to the same set (reads are ok).

◆ insert() [2/4]

ConcurrentBitset& CxxUtils::ConcurrentBitset::insert ( const ConcurrentBitset other)
inherited

Turn on bits listed in another set.

Parameters
otherSet of bits to turn on.

This is the same as operator|=, except that if the size of other is larger than this set, then this set will be expanded to match other.

This operation is incompatible with any other simultaneous writes to the same set (reads are ok).

◆ insert() [3/4]

template<class ITERATOR , typename = typename std::enable_if< std::is_base_of< typename std::forward_iterator_tag, typename std::iterator_traits<ITERATOR>::iterator_category >::value>>
ConcurrentBitset& CxxUtils::ConcurrentBitset::insert ( ITERATOR  beg,
ITERATOR  end,
bit_t  new_nbits = 0 
)
inherited

Set several bits to 1.

Expand the set if needed.

Parameters
begStart of range of bits to set.
endEnd of range of bits to set.
new_nbitsHint for new size of set, if it needs to be expanded.

The iteration range should be over something convertible to bit_t. If any bit is past the end of the container, then the container will be expanded as needed.

This operation is incompatible with any other simultaneous writes to the same set (reads are ok).

Example:

std::vector<bit_t> bits { 4, 10, 12};
bs.insert (bits.begin(), bits.end());

◆ insert() [4/4]

ConcurrentBitset& CxxUtils::ConcurrentBitset::insert ( std::initializer_list< bit_t l,
bit_t  new_nbits = 0 
)
inherited

Set several bits to 1.

Expand the set if needed.

Parameters
lList of bits to set.
new_nbitsHint for new size of set, if it needs to be expanded.

If any bit is past the end of the container, then the container will be expanded as needed.

This operation is incompatible with any other simultaneous writes to the same set (reads are ok).

Example:

std::vector<bit_t> bits { 4, 10, 12};
bs.insert ({4, 10, 12});

◆ nBlocks()

static bit_t CxxUtils::ConcurrentBitset::nBlocks ( bit_t  nbits)
staticprivateinherited

Find number of blocks needed to hold a given number of bits.

Parameters
nbitsThe number of bits.

◆ newImpl()

Impl* CxxUtils::ConcurrentBitset::newImpl ( bit_t  nbits)
privateinherited

Create a new, uninitialized implementation object.

Parameters
nbitsNumber of bits to allocate.

This will allocate memory for the Impl object, but will does not run the constructor.

◆ none()

bool CxxUtils::ConcurrentBitset::none ( ) const
inherited

Return true if there are no 1 bits in the set.

◆ operator!=()

bool CxxUtils::ConcurrentBitset::operator!= ( const ConcurrentBitset other) const
inherited

Test two sets for inequality.

Parameters
otherThe other set to test.

◆ operator&=()

ConcurrentBitset& CxxUtils::ConcurrentBitset::operator&= ( const ConcurrentBitset other)
inherited

AND this set with another set.

Parameters
otherThe other set.

This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.

◆ operator-=()

ConcurrentBitset& CxxUtils::ConcurrentBitset::operator-= ( const ConcurrentBitset other)
inherited

Subtract another set from this set.

Parameters
otherThe other set.

This is the same as (*this) &= ~other;

This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.

◆ operator==()

bool CxxUtils::ConcurrentBitset::operator== ( const ConcurrentBitset other) const
inherited

Test two sets for equality.

Parameters
otherThe other set to test.

◆ operator[]() [1/2]

reference CxxUtils::ConcurrentBitset::operator[] ( bit_t  bit)
inherited

Return a reference to one bit.

Parameters
bitThe number of the bit to reference.

The reference will be invalidated by calls to insert() or operator=. Effects are undefined if bit is past the end of the set.

◆ operator[]() [2/2]

bool CxxUtils::ConcurrentBitset::operator[] ( bit_t  bit) const
inherited

Return the value of one bit.

Parameters
bitThe number of the bit to test.

◆ operator^=()

ConcurrentBitset& CxxUtils::ConcurrentBitset::operator^= ( const ConcurrentBitset other)
inherited

XOR this set with another set.

Parameters
otherThe other set.

This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.

◆ operator|=()

ConcurrentBitset& CxxUtils::ConcurrentBitset::operator|= ( const ConcurrentBitset other)
inherited

OR this set with another set.

Parameters
otherThe other set.

This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.

◆ operator~()

ConcurrentBitset CxxUtils::ConcurrentBitset::operator~ ( ) const
inherited

Return a new set that is the complement of this set.

◆ reset() [1/2]

ConcurrentBitset& CxxUtils::ConcurrentBitset::reset ( )
inherited

Clear all bits in the set.

This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.

◆ reset() [2/2]

ConcurrentBitset& CxxUtils::ConcurrentBitset::reset ( bit_t  bit)
inherited

Turn off one bit.

Parameters
bitThe bit to turn off.

Does nothing if bit beyond the end of the set.

◆ set() [1/3]

ConcurrentBitset& CxxUtils::ConcurrentBitset::set ( )
inherited

Turn on all bits in the set.

This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.

◆ set() [2/3]

ConcurrentBitset& CxxUtils::ConcurrentBitset::set ( bit_t  bit)
inherited

Turn on one bit.

Parameters
bitThe bit to turn on.

Does nothing if bit beyond the end of the set.

◆ set() [3/3]

ConcurrentBitset& CxxUtils::ConcurrentBitset::set ( bit_t  bit,
bool  val 
)
inherited

Set the value of one bit.

Parameters
bitThe bit to turn set.
valThe value to which to set it.

Does nothing if bit beyond the end of the set.

◆ size()

bit_t CxxUtils::ConcurrentBitset::size ( ) const
inherited

Count the number of 1 bits in the set.

Note: If you regard this like a std::bitset, you would expect this to return the number of bits that the set can hold, while if you regard this like a set<bit_t>, then you would expect this to return the number of 1 bits. We follow the latter here.

◆ test()

bool CxxUtils::ConcurrentBitset::test ( bit_t  bit) const
inherited

Test to see if a bit is set.

Parameters
bitNumber of the bit to test.
Returns
true if the bit is set; false otherwise.

Returns false if bit is beyond the end of the set.

Member Data Documentation

◆ BLOCKSIZE

const size_t CxxUtils::ConcurrentBitset::BLOCKSIZE = sizeof(Block_t) * CHAR_BIT
staticprivateinherited

Size, in bits, of Block_t.

Definition at line 158 of file ConcurrentBitset.h.

◆ m_garbage

std::vector<Impl*> CxxUtils::ConcurrentBitset::m_garbage
privateinherited

Old implementation objects, pending deletion.

Definition at line 1071 of file ConcurrentBitset.h.

◆ m_impl

std::atomic<Impl*> CxxUtils::ConcurrentBitset::m_impl
privateinherited

The current implementation object.

Definition at line 1068 of file ConcurrentBitset.h.

◆ m_mutex

mutex_t CxxUtils::ConcurrentBitset::m_mutex
privateinherited

Definition at line 1076 of file ConcurrentBitset.h.

◆ MASK

const size_t CxxUtils::ConcurrentBitset::MASK = BLOCKSIZE-1
staticprivateinherited

Mask to select out the bit offset within one Block_t.

Definition at line 161 of file ConcurrentBitset.h.


The documentation for this class was generated from the following file:
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CxxUtils::ConcurrentBitset
Variable-sized bitset allowing (mostly) concurrent access.
Definition: ConcurrentBitset.h:146
CxxUtils::ConcurrentBitset::bit_t
size_t bit_t
A bit number.
Definition: ConcurrentBitset.h:164
CxxUtils::ConcurrentBitset::m_impl
std::atomic< Impl * > m_impl
The current implementation object.
Definition: ConcurrentBitset.h:1068
CxxUtils::ConcurrentBitset::lock_t
std::lock_guard< mutex_t > lock_t
Definition: ConcurrentBitset.h:1075
lumiFormat.i
int i
Definition: lumiFormat.py:92
findIdxOfMinimum::Impl
Impl
Definition: GSFFindIndexOfMinimum.h:398
CxxUtils::ConcurrentBitset::m_garbage
std::vector< Impl * > m_garbage
Old implementation objects, pending deletion.
Definition: ConcurrentBitset.h:1071
CxxUtils::ConcurrentBitset::m_mutex
mutex_t m_mutex
Definition: ConcurrentBitset.h:1076
beamspotCoolDiff.bs
bs
Definition: beamspotCoolDiff.py:148