Struct elsa::sync::LockFreeFrozenVec
source · pub struct LockFreeFrozenVec<T: Copy> { /* private fields */ }
Expand description
Append-only threadsafe version of std::vec::Vec
where
insertion does not require mutable access.
Does not lock for reading, only allows Copy
types and
will spinlock on pushes without affecting reads.
Note that this data structure is 64
pointers large on
64 bit systems,
in contrast to Vec
which is 3
pointers large.
Implementations§
source§impl<T: Copy> LockFreeFrozenVec<T>
impl<T: Copy> LockFreeFrozenVec<T>
pub fn new() -> Self
sourcepub fn push(&self, val: T) -> usize
pub fn push(&self, val: T) -> usize
Pushes an element to the vector, potentially allocating new memory. Returns the index at which the element was inserted.
sourcepub fn get(&self, index: usize) -> Option<T>
pub fn get(&self, index: usize) -> Option<T>
Load an element (if it exists). This operation is lock-free and performs minimal synchronization.
pub fn is_empty(&self) -> bool
sourcepub unsafe fn get_unchecked(&self, index: usize) -> T
pub unsafe fn get_unchecked(&self, index: usize) -> T
Load an element (if it exists). This operation is lock-free and performs no synchronized atomic operations. This is a useful primitive to implement your own data structure with newtypes around the index.
Trait Implementations§
source§impl<T: Copy> Default for LockFreeFrozenVec<T>
impl<T: Copy> Default for LockFreeFrozenVec<T>
source§impl<T: Copy> Drop for LockFreeFrozenVec<T>
impl<T: Copy> Drop for LockFreeFrozenVec<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for LockFreeFrozenVec<T>
impl<T> Send for LockFreeFrozenVec<T>
impl<T> Sync for LockFreeFrozenVec<T>
impl<T> Unpin for LockFreeFrozenVec<T>
impl<T> UnwindSafe for LockFreeFrozenVec<T>where T: RefUnwindSafe,
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