pub struct RcuArray<T: Send + Sync + 'static> { /* private fields */ }Expand description
An array-like data structure that can be read without locking.
RcuArray provides a way to share a growable array between multiple threads.
Writers create a new copy of the array when it needs to be grown, and readers
are guaranteed to see a consistent snapshot of the array without blocking
writers.
Implementations§
Source§impl<T: Send + Sync + 'static> RcuArray<T>
impl<T: Send + Sync + 'static> RcuArray<T>
Sourcepub fn get<'a>(&self, scope: &'a RcuReadScope, index: usize) -> Option<&'a T>
pub fn get<'a>(&self, scope: &'a RcuReadScope, index: usize) -> Option<&'a T>
Returns a reference to the element at the given index, or None if the
index is out of bounds.
Sourcepub fn as_slice<'a>(&self, scope: &'a RcuReadScope) -> &'a [T]
pub fn as_slice<'a>(&self, scope: &'a RcuReadScope) -> &'a [T]
Returns a slice containing the entire array.
Sourcepub unsafe fn ensure_at_least(&self, requested_size: usize)
pub unsafe fn ensure_at_least(&self, requested_size: usize)
Ensures that the array has at least requested_size elements, filling with
value if the array needs to be grown.
If the array is already large enough, this function does nothing. Otherwise,
the array is grown to at least requested_size. To avoid frequent reallocations,
the array will at least double in size.
§Safety
Requires external synchronization to exclude concurrent writers.