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 34 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 const 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
pub fn len(&self) -> usize
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.
§Safety
index must be in bounds, i.e. it must be less than self.len()