Skip to main content

RcuArray

Struct RcuArray 

Source
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>

Source

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.

Source

pub fn as_slice<'a>(&self, scope: &'a RcuReadScope) -> &'a [T]

Returns a slice containing the entire array.

Source

pub unsafe fn ensure_at_least(&self, requested_size: usize)
where T: Clone + Default,

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.

Source

pub fn update(&self, new_array: Vec<T>)

Updates the array to contain the given vector.

Trait Implementations§

Source§

impl<T: Clone + Sync + Send + 'static> Clone for RcuArray<T>

Source§

fn clone(&self) -> Self

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<T: Debug + Send + Sync + 'static> Debug for RcuArray<T>

Source§

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

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

impl<T: Default + Send + Sync + 'static> Default for RcuArray<T>

Source§

fn default() -> RcuArray<T>

Returns the “default value” for a type. Read more
Source§

impl<T: Send + Sync + 'static> From<Vec<T>> for RcuArray<T>

Creates an RcuArray from a Vec<T>.

Source§

fn from(value: Vec<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> !Freeze for RcuArray<T>

§

impl<T> RefUnwindSafe for RcuArray<T>

§

impl<T> Send for RcuArray<T>

§

impl<T> Sync for RcuArray<T>

§

impl<T> Unpin for RcuArray<T>

§

impl<T> UnsafeUnpin for RcuArray<T>

§

impl<T> UnwindSafe for RcuArray<T>
where T: RefUnwindSafe,

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> 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> 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> 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.