ATLAS Offline Software
|
Implementation object. More...
Public Types | |
typedef void | operator_t(std::atomic< Block_t > &a, Block_t v) |
Public Member Functions | |
void * | operator new (size_t, bit_t nbits) |
Allocate an Impl structure. More... | |
void | operator delete (void *p) |
Impl (bit_t nbits) | |
Constructor. More... | |
Impl (const Impl &other, bit_t nbits=0) | |
Copy constructor. More... | |
Impl & | operator= (const Impl &)=delete |
void | assign (const Impl &other) |
Copy from another instance. More... | |
bit_t | nbits () const |
Return the number of bits in the set. More... | |
bool | test (bit_t bit) const |
Test to see if a bit is set. More... | |
bit_t | count () const |
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... | |
std::atomic< Block_t > * | block (bit_t bit) |
Return a pointer to the block containing bit . More... | |
void | set (bit_t bit) |
Turn on one bit. More... | |
void | reset (bit_t bit) |
Turn off one bit. More... | |
void | flip (bit_t bit) |
Flip the value of one bit. More... | |
void | clear () |
Clear all bits in the set. More... | |
void | set () |
Turn on all bits in the set. More... | |
void | flip () |
Flip the state of all bits in the set. More... | |
void | operate (operator_t op, const Impl &other) |
Apply a binary operation. More... | |
bool | operator== (const Impl &other) const |
Compare with another set. More... | |
const_iterator | begin () const |
Return an iterator referencing the first 1 bit. More... | |
const_iterator | end () const |
Return the end iterator. More... | |
const_iterator | find (bit_t bit) const |
If bit bit is set, return an iterator pointing to it. More... | |
Private Attributes | |
size_t | m_nbits |
Number of bits in the container. More... | |
size_t | m_nblocks |
Number of blocks in the container. More... | |
std::atomic< size_t > | m_hwm |
High-water mark: index of last block with a 1 bit. More... | |
std::atomic< Block_t > | m_data [1] |
The set data. More... | |
Implementation object.
An instance of this holds the set data for a fixed size. If the set needs to be expanded, a new implementation object must be allocated and the data copied.
This object consists of a fixed header, followed by a variable-sized array containing the actual set data. In this class, the array is declared with a size of 1; however, we allocate these objects (using the newImpl
function) with enough space to hold the entire set.
This class also contains the basic methods for operating on the set.
Definition at line 845 of file ConcurrentBitset.h.
Definition at line 1005 of file ConcurrentBitset.h.
CxxUtils::ConcurrentBitset::Impl::Impl | ( | bit_t | nbits | ) |
Constructor.
nbits | Number of bits in the set. |
Copy constructor.
Other object to copy.
Number of bits to use for this container.
If nbits
is smaller than the size of other
, then the size of other
will be used instead.
bool CxxUtils::ConcurrentBitset::Impl::all | ( | ) | const |
Copy from another instance.
other | Object from which to copy. |
This does not change the size of the container. If This container is larger than other
, then the remainder will be filled with zeros. If other
is larger than this container, then the remainder will be ignored.
const_iterator CxxUtils::ConcurrentBitset::Impl::begin | ( | ) | const |
Return an iterator referencing the first 1 bit.
Return a pointer to the block containing bit
.
bit | Desired bit number. |
Returns nullptr if bit
is past the end of the set.
void CxxUtils::ConcurrentBitset::Impl::clear | ( | ) |
Clear all bits in the set.
This operation is not necessarily atomic; a simultaneous read may be able to see the operation partially done.
ConcurrentBitset::bit_t CxxUtils::ConcurrentBitset::Impl::count | ( | ) | const |
const_iterator CxxUtils::ConcurrentBitset::Impl::end | ( | ) | const |
Return the end iterator.
const_iterator CxxUtils::ConcurrentBitset::Impl::find | ( | bit_t | bit | ) | const |
If bit bit
is set, return an iterator pointing to it.
Otherwise, return an end iterator.
bit | Bit number to test. |
void CxxUtils::ConcurrentBitset::Impl::flip | ( | ) |
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.
Definition at line 276 of file ConcurrentBitset.cxx.
void CxxUtils::ConcurrentBitset::Impl::flip | ( | bit_t | bit | ) |
Flip the value of one bit.
bit | The bit to turn flip. |
Does nothing if bit
beyond the end of the set.
bit_t CxxUtils::ConcurrentBitset::Impl::nbits | ( | ) | const |
Return the number of bits in the set.
bool CxxUtils::ConcurrentBitset::Impl::none | ( | ) | const |
void CxxUtils::ConcurrentBitset::Impl::operate | ( | operator_t | op, |
const Impl & | other | ||
) |
Apply a binary operation.
op | Operation to apply. |
other | Second set for the operation. |
Each block B in this set is replaced by B OP OTHER, where OTHER is the corresponding block in the other container. (If this set is larger than other
, then the trailing blocks will be 0.)
void CxxUtils::ConcurrentBitset::Impl::operator delete | ( | void * | p | ) |
void* CxxUtils::ConcurrentBitset::Impl::operator new | ( | size_t | , |
bit_t | nbits | ||
) |
Compare with another set.
other | Other set with which to compare. |
void CxxUtils::ConcurrentBitset::Impl::reset | ( | bit_t | bit | ) |
Turn off one bit.
bit | The bit to turn off. |
Does nothing if bit
beyond the end of the set.
void CxxUtils::ConcurrentBitset::Impl::set | ( | ) |
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.
Definition at line 258 of file ConcurrentBitset.cxx.
void CxxUtils::ConcurrentBitset::Impl::set | ( | bit_t | bit | ) |
Turn on one bit.
bit | The bit to turn on. |
Does nothing if bit
beyond the end of the set.
bool CxxUtils::ConcurrentBitset::Impl::test | ( | bit_t | bit | ) | const |
Test to see if a bit is set.
bit | Number of the bit to test. |
Returns false if bit
is beyond the end of the set.
|
private |
The set data.
The implementation objects are allocated such that there are actually m_nblocks entries available in this array.
Definition at line 1059 of file ConcurrentBitset.h.
|
private |
High-water mark: index of last block with a 1 bit.
Definition at line 1054 of file ConcurrentBitset.h.
|
private |
Number of bits in the container.
Definition at line 1048 of file ConcurrentBitset.h.
|
private |
Number of blocks in the container.
Definition at line 1051 of file ConcurrentBitset.h.