Struct hibitset::AtomicBitSet
source · pub struct AtomicBitSet { /* private fields */ }
Expand description
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.
Implementations§
source§impl AtomicBitSet
impl AtomicBitSet
sourcepub fn new() -> AtomicBitSet
pub fn new() -> AtomicBitSet
Creates an empty AtomicBitSet
.
sourcepub fn add_atomic(&self, id: u32) -> bool
pub fn add_atomic(&self, id: u32) -> 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.
sourcepub fn add(&mut self, id: u32) -> bool
pub fn add(&mut self, id: u32) -> bool
Adds id
to the BitSet
. Returns true
if the value was
already in the set.
Trait Implementations§
source§impl<'a, T> BitAnd<T> for &'a AtomicBitSetwhere
T: BitSetLike,
impl<'a, T> BitAnd<T> for &'a AtomicBitSetwhere
T: BitSetLike,
source§impl<T> BitAnd<T> for AtomicBitSetwhere
T: BitSetLike,
impl<T> BitAnd<T> for AtomicBitSetwhere
T: BitSetLike,
source§impl<'a, T> BitOr<T> for &'a AtomicBitSetwhere
T: BitSetLike,
impl<'a, T> BitOr<T> for &'a AtomicBitSetwhere
T: BitSetLike,
source§impl<T> BitOr<T> for AtomicBitSetwhere
T: BitSetLike,
impl<T> BitOr<T> for AtomicBitSetwhere
T: BitSetLike,
source§impl BitSetLike for AtomicBitSet
impl BitSetLike for AtomicBitSet
source§fn layer3(&self) -> usize
fn layer3(&self) -> usize
usize
where each bit represents if any word in layer2
has been set.source§fn layer2(&self, i: usize) -> usize
fn layer2(&self, i: usize) -> usize
usize
from the array of usizes that indicates if any
bit has been set in layer1source§fn layer1(&self, i: usize) -> usize
fn layer1(&self, i: usize) -> usize
usize
from the array of usizes that indicates if any
bit has been set in layer0source§fn layer0(&self, i: usize) -> usize
fn layer0(&self, i: usize) -> usize
usize
that maps to the direct 1:1 association with
each index of the setsource§fn get_from_layer(&self, layer: usize, idx: usize) -> usize
fn get_from_layer(&self, layer: usize, idx: usize) -> usize
usize
corresponding to layer and index. Read moresource§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
BitSetLike
contains nothing, and false otherwise.source§fn iter(self) -> BitIter<Self> ⓘwhere
Self: Sized,
fn iter(self) -> BitIter<Self> ⓘwhere
Self: Sized,
source§fn par_iter(self) -> BitParIter<Self>where
Self: Sized,
fn par_iter(self) -> BitParIter<Self>where
Self: Sized,
source§impl<'a, T> BitXor<T> for &'a AtomicBitSetwhere
T: BitSetLike,
impl<'a, T> BitXor<T> for &'a AtomicBitSetwhere
T: BitSetLike,
source§impl<T> BitXor<T> for AtomicBitSetwhere
T: BitSetLike,
impl<T> BitXor<T> for AtomicBitSetwhere
T: BitSetLike,
source§impl Debug for AtomicBitSet
impl Debug for AtomicBitSet
source§impl Default for AtomicBitSet
impl Default for AtomicBitSet
source§impl DrainableBitSet for AtomicBitSet
impl DrainableBitSet for AtomicBitSet
source§impl<'a> Extend<&'a u32> for AtomicBitSet
impl<'a> Extend<&'a u32> for AtomicBitSet
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = &'a u32>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = &'a u32>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Extend<u32> for AtomicBitSet
impl Extend<u32> for AtomicBitSet
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = u32>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = u32>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)