pub struct SyncPushVec<T> { /* private fields */ }
Expand description
A contiguous push-only array type with lock-free reads.
Implementations§
Source§impl<T> SyncPushVec<T>
impl<T> SyncPushVec<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new, empty vector with zero capacity.
The vector will not allocate until elements are pushed onto it.
Sourcepub fn with_capacity(capacity: usize) -> Self
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.
Sourcepub fn mutex(&self) -> &Mutex<()>
pub fn mutex(&self) -> &Mutex<()>
Gets a reference to the underlying mutex that protects writes.
Sourcepub fn read<'a>(&'a self, pin: Pin<'a>) -> Read<'a, T>
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.
Sourcepub unsafe fn unsafe_write(&self) -> Write<'_, T>
pub unsafe fn unsafe_write(&self) -> Write<'_, T>
Sourcepub fn lock(&self) -> LockedWrite<'_, T>
pub fn lock(&self) -> LockedWrite<'_, T>
Creates a LockedWrite handle by taking the underlying mutex that protects writes.
Sourcepub fn lock_from_guard<'a>(
&'a self,
guard: MutexGuard<'a, ()>,
) -> LockedWrite<'a, T>
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.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
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>
impl<T> Default for SyncPushVec<T>
Source§impl<T> Drop for SyncPushVec<T>
impl<T> Drop for SyncPushVec<T>
Source§impl<T: Clone + Send> FromIterator<T> for SyncPushVec<T>
impl<T: Clone + Send> FromIterator<T> for SyncPushVec<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<T: Send> Send for SyncPushVec<T>
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> 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