pub struct Block<T> {
len: AtomicUsize,
data: AtomicPtr<WriteOnce<T>>,
}Expand description
An allocation that can store a fixed number of elements.
Fields§
§len: AtomicUsizeThe number of elements in the block.
data: AtomicPtr<WriteOnce<T>>A pointer to the data buffer.
If size is nonzero, this points to a slice of WriteOnce<T> of that size. If size is
zero, this is a null pointer.
It would be more convenient to use AtomicPtr<[WriteOnce<T>] here. However, AtomicPtr<T>
requires T: Sized. This is because pointers to DSTs are fat, and take two words in memory.
Most architectures can operate atomically on at most one word.
Implementations§
Source§impl<T> Block<T>
impl<T> Block<T>
pub(super) fn is_init(&self) -> bool
pub(super) fn data(&self) -> &AtomicPtr<WriteOnce<T>>
Sourcepub(super) unsafe fn init(&self, size: NonZero<usize>)
pub(super) unsafe fn init(&self, size: NonZero<usize>)
Initialize the block with a given size.
§Safety
For any given block, this method must always be called with the same size.
Sourcepub(super) unsafe fn try_insert(&self, index: usize, value: T) -> Result<(), T>
pub(super) unsafe fn try_insert(&self, index: usize, value: T) -> Result<(), T>
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Block<T>
impl<T> RefUnwindSafe for Block<T>
impl<T> Send for Block<T>
impl<T> Sync for Block<T>
impl<T> Unpin for Block<T>
impl<T> !UnwindSafe for Block<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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