pub struct OnceMutex<T> { /* private fields */ }
Expand description
A mutex which can only be locked once, but which provides very fast, lock-free, concurrent reads after the first lock is over.
Implementations§
Source§impl<T: Send + Sync> OnceMutex<T>
impl<T: Send + Sync> OnceMutex<T>
Sourcepub fn lock(&self) -> Option<OnceMutexGuard<'_, T>>
pub fn lock(&self) -> Option<OnceMutexGuard<'_, T>>
Attempt to lock the OnceMutex.
This will not block, but will return None if the OnceMutex has already been locked or is currently locked by another thread.
Sourcepub fn wait(&self)
pub fn wait(&self)
Block the current task until the first lock is over.
Does nothing if there is no lock.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Extract the data from a OnceMutex.
Trait Implementations§
impl<T: Send> Send for OnceMutex<T>
impl<T: Sync> Sync for OnceMutex<T>
Auto Trait Implementations§
impl<T> !Freeze for OnceMutex<T>
impl<T> !RefUnwindSafe for OnceMutex<T>
impl<T> Unpin for OnceMutex<T>where
T: Unpin,
impl<T> UnwindSafe for OnceMutex<T>where
T: UnwindSafe,
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