pub struct SharedLock<T>(/* private fields */);Expand description
Thread-safe shared mutable value using Mutex for exclusive access.
Implementations§
Sourcepub fn with<F, R>(&self, f: F) -> Result<R, PoisonError<MutexGuard<'_, T>>>
pub fn with<F, R>(&self, f: F) -> Result<R, PoisonError<MutexGuard<'_, T>>>
Execute a closure with mutable access to the inner value.
Caution: f runs while the mutex is held. Avoid re-entering this
SharedLock from inside the closure.
Sourcepub fn get(&self) -> Result<T, PoisonError<MutexGuard<'_, T>>>where
T: Clone,
pub fn get(&self) -> Result<T, PoisonError<MutexGuard<'_, T>>>where
T: Clone,
Get a cloned snapshot of the value.
Sourcepub fn set(&self, value: T) -> Result<(), PoisonError<MutexGuard<'_, T>>>
pub fn set(&self, value: T) -> Result<(), PoisonError<MutexGuard<'_, T>>>
Replace the inner value.
Trait Implementations§
Auto Trait Implementations§
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