Skip to main content

AtomicBitSlice

Struct AtomicBitSlice 

Source
pub struct AtomicBitSlice<A, V>(/* private fields */);
Expand description

Unsized shared base for multi-word atomic bitset types.

AtomicBitSlice<A, V> is to atomic bitsets what BitSlice<T, V> is to non-atomic ones: a #[repr(transparent)] wrapper around [A] that provides common query and mutation methods. Owned types (AtomicBitSet<[A; N], V> and AtomicBoxedBitSet<A, V>) implement Deref<Target = AtomicBitSlice<A, V>>.

§Atomicity guarantees

Each individual method (insert, remove, contains, …) performs atomic operations per word. However, the bitset as a whole is not a single atomic unit when it spans multiple words. Concurrent modifications to bits within the same word are correctly synchronized via fetch_or / fetch_and with AcqRel ordering. Modifications to bits in different words are independent atomic operations — there is no cross-word transactional guarantee.

Read-only methods (len, iter, contains, is_subset, …) load each word with Relaxed ordering and do not take a consistent snapshot of the entire bitset. If another thread modifies the set concurrently, these methods may observe a mix of old and new state across different words.

Implementations§

Source§

impl<A, V> AtomicBitSlice<A, V>

Source

pub fn as_raw_slice(&self) -> &[A]

Source§

impl<A, V> AtomicBitSlice<A, V>
where A: Radium, A::Item: PrimInt,

Source

pub fn capacity(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn first(&self) -> Option<V>
where V: TryFrom<usize>,

Source

pub fn last(&self) -> Option<V>
where V: TryFrom<usize>,

Source

pub fn pop_first(&self) -> Option<V>
where V: TryFrom<usize>, A::Item: BitOps,

Source

pub fn pop_last(&self) -> Option<V>
where V: TryFrom<usize>, A::Item: BitOps,

Source

pub fn contains(&self, id: &V) -> bool
where V: Copy + AsPrimitive<usize>,

Source

pub fn insert(&self, id: V) -> bool
where V: AsPrimitive<usize>, A::Item: BitOps,

Source

pub fn remove(&self, id: V) -> bool
where V: AsPrimitive<usize>, A::Item: BitOps,

Source

pub fn set(&self, id: V, value: bool)
where V: AsPrimitive<usize>, A::Item: BitOps,

Source

pub fn toggle(&self, id: V)
where V: AsPrimitive<usize>, A::Item: BitOps,

Source

pub fn clear(&self)

Source

pub fn retain(&self, f: impl FnMut(V) -> bool)
where V: TryFrom<usize>, A::Item: BitOps,

Source

pub fn iter(&self) -> impl Iterator<Item = V> + '_
where A::Item: BitAndAssign, V: TryFrom<usize>,

Source

pub fn is_subset(&self, other: &Self) -> bool

Source

pub fn is_superset(&self, other: &Self) -> bool

Source

pub fn is_disjoint(&self, other: &Self) -> bool

Source

pub fn union_from(&self, other: &[A::Item])
where A::Item: BitOps + Copy,

Auto Trait Implementations§

§

impl<A, V> Freeze for AtomicBitSlice<A, V>
where A: Freeze,

§

impl<A, V> RefUnwindSafe for AtomicBitSlice<A, V>

§

impl<A, V> Send for AtomicBitSlice<A, V>
where V: Send, A: Send,

§

impl<A, V> !Sized for AtomicBitSlice<A, V>

§

impl<A, V> Sync for AtomicBitSlice<A, V>
where V: Sync, A: Sync,

§

impl<A, V> Unpin for AtomicBitSlice<A, V>
where V: Unpin, A: Unpin,

§

impl<A, V> UnsafeUnpin for AtomicBitSlice<A, V>
where A: UnsafeUnpin,

§

impl<A, V> UnwindSafe for AtomicBitSlice<A, V>
where V: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more