Struct SyncPushVec

Source
pub struct SyncPushVec<T> { /* private fields */ }
Expand description

A contiguous push-only array type with lock-free reads.

Implementations§

Source§

impl<T> SyncPushVec<T>

Source

pub fn new() -> Self

Constructs a new, empty vector with zero capacity.

The vector will not allocate until elements are pushed onto it.

Source

pub fn with_capacity(capacity: usize) -> Self

Constructs a new, empty vector with the specified capacity.

The vector will be able to hold exactly capacity elements without reallocating. If capacity is 0, the vector will not allocate.

Source

pub fn mutex(&self) -> &Mutex<()>

Gets a reference to the underlying mutex that protects writes.

Source

pub fn read<'a>(&'a self, pin: Pin<'a>) -> Read<'a, T>

Creates a Read handle from a pinned region.

Use crate::collect::pin to get a Pin instance.

Source

pub unsafe fn unsafe_write(&self) -> Write<'_, T>

Creates a Write handle without checking for exclusive access.

§Safety

It’s up to the caller to ensure only one thread writes to the vector at a time.

Source

pub fn write(&mut self) -> Write<'_, T>

Creates a Write handle from a mutable reference.

Source

pub fn lock(&self) -> LockedWrite<'_, T>

Creates a LockedWrite handle by taking the underlying mutex that protects writes.

Source

pub fn lock_from_guard<'a>( &'a self, guard: MutexGuard<'a, ()>, ) -> LockedWrite<'a, T>

Creates a LockedWrite handle from a guard protecting the underlying mutex that protects writes.

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Extracts a mutable slice of the entire vector.

Trait Implementations§

Source§

impl<T> Default for SyncPushVec<T>

Source§

fn default() -> Self

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

impl<T> Drop for SyncPushVec<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: Clone + Send> FromIterator<T> for SyncPushVec<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Send> Send for SyncPushVec<T>

Source§

impl<T: Sync> Sync for SyncPushVec<T>

Auto Trait Implementations§

§

impl<T> !Freeze for SyncPushVec<T>

§

impl<T> !RefUnwindSafe for SyncPushVec<T>

§

impl<T> Unpin for SyncPushVec<T>
where T: Unpin,

§

impl<T> !UnwindSafe for SyncPushVec<T>

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