proxygen
|
#include <AtomicBitSet.h>
Public Member Functions | |
AtomicBitSet () | |
bool | set (size_t idx, std::memory_order order=std::memory_order_seq_cst) |
bool | reset (size_t idx, std::memory_order order=std::memory_order_seq_cst) |
bool | set (size_t idx, bool value, std::memory_order order=std::memory_order_seq_cst) |
bool | test (size_t idx, std::memory_order order=std::memory_order_seq_cst) const |
bool | operator[] (size_t idx) const |
constexpr size_t | size () const |
Private Types | |
typedef unsigned int | BlockType |
typedef std::atomic< BlockType > | AtomicBlockType |
Static Private Member Functions | |
static constexpr size_t | blockIndex (size_t bit) |
static constexpr size_t | bitOffset (size_t bit) |
Private Attributes | |
std::array< AtomicBlockType, N > | data_ |
Static Private Attributes | |
static constexpr size_t | kBitsPerBlock |
static constexpr BlockType | kOne = 1 |
An atomic bitset of fixed size (specified at compile time).
Definition at line 35 of file AtomicBitSet.h.
|
private |
Definition at line 103 of file AtomicBitSet.h.
|
private |
Definition at line 101 of file AtomicBitSet.h.
|
inline |
Construct an AtomicBitSet; all bits are initially false.
Definition at line 124 of file AtomicBitSet.h.
|
inlinestaticprivate |
Definition at line 112 of file AtomicBitSet.h.
References folly::AtomicBitSet< N >::kBitsPerBlock.
Referenced by folly::AtomicBitSet< N >::reset(), folly::AtomicBitSet< N >::set(), and folly::AtomicBitSet< N >::test().
|
inlinestaticprivate |
Definition at line 108 of file AtomicBitSet.h.
References folly::AtomicBitSet< N >::kBitsPerBlock.
Referenced by folly::AtomicBitSet< N >::reset(), folly::AtomicBitSet< N >::set(), and folly::AtomicBitSet< N >::test().
|
inline |
Same as test() with the default memory order.
Definition at line 154 of file AtomicBitSet.h.
References folly::AtomicBitSet< N >::test().
|
inline |
Set bit idx to false, using the given memory order. Returns the previous value of the bit.
Note that the operation is a read-modify-write operation due to the use of fetch_and.
Definition at line 134 of file AtomicBitSet.h.
References folly::AtomicBitSet< N >::bitOffset(), folly::AtomicBitSet< N >::blockIndex(), folly::AtomicBitSet< N >::data_, folly::AtomicBitSet< N >::kBitsPerBlock, and folly::AtomicBitSet< N >::kOne.
Referenced by folly::AtomicBitSet< N >::set(), and folly::test::TEST().
|
inline |
Set bit idx to true, using the given memory order. Returns the previous value of the bit.
Note that the operation is a read-modify-write operation due to the use of fetch_or.
Definition at line 127 of file AtomicBitSet.h.
References folly::AtomicBitSet< N >::bitOffset(), folly::AtomicBitSet< N >::blockIndex(), folly::AtomicBitSet< N >::data_, folly::AtomicBitSet< N >::kBitsPerBlock, and folly::AtomicBitSet< N >::kOne.
Referenced by folly::test::TEST().
|
inline |
Set bit idx to the given value, using the given memory order. Returns the previous value of the bit.
Note that the operation is a read-modify-write operation due to the use of fetch_and or fetch_or.
Yes, this is an overload of set(), to keep as close to std::bitset's interface as possible.
Definition at line 142 of file AtomicBitSet.h.
References order, and folly::AtomicBitSet< N >::reset().
|
inline |
Return the size of the bitset.
Definition at line 89 of file AtomicBitSet.h.
Referenced by folly::test::TEST().
|
inline |
Read bit idx.
Definition at line 147 of file AtomicBitSet.h.
References folly::AtomicBitSet< N >::bitOffset(), folly::AtomicBitSet< N >::blockIndex(), folly::AtomicBitSet< N >::data_, folly::AtomicBitSet< N >::kBitsPerBlock, and folly::AtomicBitSet< N >::kOne.
Referenced by folly::AtomicBitSet< N >::operator[]().
|
private |
Definition at line 119 of file AtomicBitSet.h.
Referenced by folly::AtomicBitSet< N >::reset(), folly::AtomicBitSet< N >::set(), and folly::AtomicBitSet< N >::test().
|
staticprivate |
Definition at line 105 of file AtomicBitSet.h.
Referenced by folly::AtomicBitSet< N >::bitOffset(), folly::AtomicBitSet< N >::blockIndex(), folly::AtomicBitSet< N >::reset(), folly::AtomicBitSet< N >::set(), and folly::AtomicBitSet< N >::test().
|
staticprivate |
Definition at line 117 of file AtomicBitSet.h.
Referenced by folly::AtomicBitSet< N >::reset(), folly::AtomicBitSet< N >::set(), and folly::AtomicBitSet< N >::test().