Struct constellation::bitset::AtomicBitSet
[−]
[src]
pub struct AtomicBitSet { /* fields omitted */ }
This is similar to a BitSet
but allows setting of value
without unique ownership of the structure
An AtomicBitSet has the ability to add an item to the set without unique ownership (given that the set is big enough). Removing elements does require unique ownership as an effect of the hierarchy it holds. Worst case multiple writers set the same bit twice (but only is told they set it).
It is possible to atomically remove from the set, but not at the same time as atomically adding. This is because there is no way to know if layer 1-3 would be left in a consistent state if they are being cleared and set at the same time.
AtromicBitSet
resolves this race by disallowing atomic
clearing of bits.
Methods
impl AtomicBitSet
[src]
fn new() -> AtomicBitSet
Creates an empty BitSet
.
fn add_atomic(&self, id: Index) -> bool
Adds id
to the AtomicBitSet
. Returns true
if the value was
already in the set.
Because we cannot safely extend an AtomicBitSet without unique ownership this will panic if the Index is out of range
fn add(&mut self, id: Index) -> bool
Adds id
to the BitSet
. Returns true
if the value was
already in the set.
fn remove(&mut self, id: Index) -> bool
Removes id
from the set, returns true
if the value
was removed, and false
if the value was not set
to begin with.
fn contains(&self, id: Index) -> bool
Returns true
if id
is in the set.
fn clear(&mut self)
Clear all bits in the set
Trait Implementations
impl BitSetLike for AtomicBitSet
[src]
fn layer3(&self) -> usize
Return a usize where each bit represents if any word in layer2 has been set. Read more
fn layer2(&self, i: usize) -> usize
Return the usize from the array of usizes that indicates if any bit has been set in layer1 Read more
fn layer1(&self, i: usize) -> usize
Return the usize from the array of usizes that indicates if any bit has been set in layer0 Read more
fn layer0(&self, i: usize) -> usize
Return a usize that maps to the direct 1:1 association with each index of the set Read more
fn iter(self) -> BitIter<Self> where
Self: Sized,
Self: Sized,
Create an iterator that will scan over the keyspace