AtomicBitFieldVec

Struct AtomicBitFieldVec 

Source
pub struct AtomicBitFieldVec<W: Word + IntoAtomic = usize, B = Vec<<W as IntoAtomic>::AtomicType>> { /* private fields */ }
Expand description

A tentatively thread-safe vector of bit fields of fixed width (AKA “compact arrays“, “bit array“, etc.)

This implementation provides some concurrency guarantees, albeit not full-fledged thread safety: more precisely, we can guarantee thread-safety if the bit width is a power of two; otherwise, concurrent writes to values that cross word boundaries might end up in different threads succeeding in writing only part of a value. If the user can guarantee that no two threads ever write to the same boundary-crossing value, then no race condition can happen.

See the module documentation for more details.

Implementations§

Source§

impl<W: Word + IntoAtomic, B> AtomicBitFieldVec<W, B>

Source

pub unsafe fn from_raw_parts(bits: B, bit_width: usize, len: usize) -> Self

§Safety

len * bit_width must be between 0 (included) the number of bits in bits (included).

Source

pub fn into_raw_parts(self) -> (B, usize, usize)

Source

pub fn mask(&self) -> W

Returns the mask used to extract values from the vector. This will keep the lowest bit_width bits.

Source§

impl<W: Word + IntoAtomic, B: AsRef<[W::AtomicType]>> AtomicBitFieldVec<W, B>

Source

pub fn as_slice(&self) -> &[W::AtomicType]

Returns the backend of the AtomicBitFieldVec as a slice of A, where A is the atomic variant of W.

Source§

impl<W: Word + IntoAtomic> AtomicBitFieldVec<W>

Source

pub fn new(bit_width: usize, len: usize) -> AtomicBitFieldVec<W>

Source§

impl<W: Word + IntoAtomic, B: AsRef<[W::AtomicType]>> AtomicBitFieldVec<W, B>

Source

pub fn reset(&mut self, ordering: Ordering)

👎Deprecated since 0.4.4: reset is deprecated in favor of reset_atomic

Writes zeros in all values.

Trait Implementations§

Source§

impl<W: Word + IntoAtomic, T: AsRef<[W::AtomicType]>> AtomicBitFieldSlice<W> for AtomicBitFieldVec<W, T>

Source§

fn set_atomic(&self, index: usize, value: W, order: Ordering)

Sets the element of the slice at the specified index.

May panic if the index is not in in [0..len) or the value does not fit in BitWidth::bit_width bits.

Source§

fn len(&self) -> usize

Source§

unsafe fn get_atomic_unchecked(&self, index: usize, order: Ordering) -> W

Returns the value at the specified index. Read more
Source§

unsafe fn set_atomic_unchecked(&self, index: usize, value: W, order: Ordering)

Sets the element of the slice at the specified index. Read more
Source§

fn reset_atomic(&mut self, ordering: Ordering)

Sets all values to zero. Read more
Source§

fn par_reset_atomic(&mut self, ordering: Ordering)

Sets all values to zero using a parallel implementation. Read more
Source§

fn is_empty(&self) -> bool

Source§

fn get_atomic(&self, index: usize, order: Ordering) -> W

Returns the value at the specified index. Read more
Source§

impl<W: Word + IntoAtomic, B> BitWidth<<W as IntoAtomic>::AtomicType> for AtomicBitFieldVec<W, B>

Source§

fn bit_width(&self) -> usize

Returns the width of the slice. Read more
Source§

impl<W: Clone + Word + IntoAtomic, B: Clone> Clone for AtomicBitFieldVec<W, B>

Source§

fn clone(&self) -> AtomicBitFieldVec<W, B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<W, B> CopyType for AtomicBitFieldVec<W, B>

Source§

impl<W: Debug + Word + IntoAtomic, B: Debug> Debug for AtomicBitFieldVec<W, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W: Word + IntoAtomic> From<AtomicBitFieldVec<W>> for BitFieldVec<W, Vec<W>>

Source§

fn from(value: AtomicBitFieldVec<W, Vec<W::AtomicType>>) -> Self

Converts to this type from the input type.
Source§

impl<'a, W: Word + IntoAtomic> From<AtomicBitFieldVec<W, &'a [<W as IntoAtomic>::AtomicType]>> for BitFieldVec<W, &'a [W]>

Source§

fn from(value: AtomicBitFieldVec<W, &'a [W::AtomicType]>) -> Self

Converts to this type from the input type.
Source§

impl<'a, W: Word + IntoAtomic> From<AtomicBitFieldVec<W, &'a mut [<W as IntoAtomic>::AtomicType]>> for BitFieldVec<W, &'a mut [W]>

Source§

fn from(value: AtomicBitFieldVec<W, &'a mut [W::AtomicType]>) -> Self

Converts to this type from the input type.
Source§

impl<W: Word + IntoAtomic> From<AtomicBitFieldVec<W, Box<[<W as IntoAtomic>::AtomicType]>>> for BitFieldVec<W, Box<[W]>>

Source§

fn from(value: AtomicBitFieldVec<W, Box<[W::AtomicType]>>) -> Self

Converts to this type from the input type.
Source§

impl<W: Word + IntoAtomic> From<BitFieldVec<W>> for AtomicBitFieldVec<W, Vec<W::AtomicType>>

Source§

fn from(value: BitFieldVec<W, Vec<W>>) -> Self

Converts to this type from the input type.
Source§

impl<W: Word + IntoAtomic> From<BitFieldVec<W, Box<[W]>>> for AtomicBitFieldVec<W, Box<[W::AtomicType]>>

Source§

fn from(value: BitFieldVec<W, Box<[W]>>) -> Self

Converts to this type from the input type.
Source§

impl<W: Hash + Word + IntoAtomic, B: Hash> Hash for AtomicBitFieldVec<W, B>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<W, B> MemDbgImpl for AtomicBitFieldVec<W, B>

Source§

fn _mem_dbg_rec_on( &self, _memdbg_writer: &mut impl Write, _memdbg_total_size: usize, _memdbg_max_depth: usize, _memdbg_prefix: &mut String, _memdbg_is_last: bool, _memdbg_flags: DbgFlags, ) -> Result

Source§

fn _mem_dbg_depth_on( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, ) -> Result<(), Error>

Source§

impl<W, B> MemSize for AtomicBitFieldVec<W, B>

Source§

fn mem_size(&self, _memsize_flags: SizeFlags) -> usize

Returns the (recursively computed) overall memory size of the structure in bytes.
Source§

impl<W: Word + IntoAtomic, T: AsRef<[W::AtomicType]>> SliceByValue for AtomicBitFieldVec<W, T>

Source§

type Value = W

The type of the values in the slice.
Source§

fn len(&self) -> usize

Source§

unsafe fn get_value_unchecked(&self, index: usize) -> Self::Value

Source§

fn is_empty(&self) -> bool

Source§

fn index_value(&self, index: usize) -> Self::Value

Source§

fn get_value(&self, index: usize) -> Option<Self::Value>

Source§

impl<'a, W: Word + IntoAtomic> TryFrom<BitFieldVec<W, &'a [W]>> for AtomicBitFieldVec<W, &'a [W::AtomicType]>

Source§

type Error = CannotCastToAtomicError<W>

The type returned in the event of a conversion error.
Source§

fn try_from(value: BitFieldVec<W, &'a [W]>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, W: Word + IntoAtomic> TryFrom<BitFieldVec<W, &'a mut [W]>> for AtomicBitFieldVec<W, &'a mut [W::AtomicType]>

Source§

type Error = CannotCastToAtomicError<W>

The type returned in the event of a conversion error.
Source§

fn try_from(value: BitFieldVec<W, &'a mut [W]>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<W, B> Freeze for AtomicBitFieldVec<W, B>
where B: Freeze, W: Freeze,

§

impl<W, B> RefUnwindSafe for AtomicBitFieldVec<W, B>

§

impl<W, B> Send for AtomicBitFieldVec<W, B>
where B: Send,

§

impl<W, B> Sync for AtomicBitFieldVec<W, B>
where B: Sync,

§

impl<W, B> Unpin for AtomicBitFieldVec<W, B>
where B: Unpin, W: Unpin,

§

impl<W, B> UnwindSafe for AtomicBitFieldVec<W, B>
where B: UnwindSafe, W: 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
Source§

impl<T> CastableFrom<T> for T

Source§

fn cast_from(value: T) -> T

Call Self as W
Source§

impl<T, U> CastableInto<U> for T
where U: CastableFrom<T>,

Source§

fn cast(self) -> U

Call W::cast_from(self)
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DowncastableFrom<T> for T

Source§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
Source§

impl<T, U> DowncastableInto<U> for T
where U: DowncastableFrom<T>,

Source§

fn downcast(self) -> U

Call W::downcast_from(self)
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MemDbg for T
where T: MemDbgImpl,

Source§

fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>

Writes to stderr debug infos about the structure memory usage, expanding all levels of nested structures.
Source§

fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags, ) -> Result<(), Error>

Writes to a core::fmt::Write debug infos about the structure memory usage, expanding all levels of nested structures.
Source§

fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>

Writes to stderr debug infos about the structure memory usage as mem_dbg, but expanding only up to max_depth levels of nested structures.
Source§

fn mem_dbg_depth_on( &self, writer: &mut impl Write, max_depth: usize, flags: DbgFlags, ) -> Result<(), Error>

Writes to a core::fmt::Write debug infos about the structure memory usage as mem_dbg_on, but expanding only up to max_depth levels of nested structures.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Splat<T> for T

Source§

fn splat(value: T) -> T

Source§

impl<T> To<T> for T

Source§

fn to(self) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UpcastableFrom<T> for T

Source§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
Source§

impl<T, U> UpcastableInto<U> for T
where U: UpcastableFrom<T>,

Source§

fn upcast(self) -> U

Call W::upcast_from(self)
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V