pub struct Slock<T> { /* private fields */ }
Expand description
The Slock
object.
An atomically reference counted read/write lock with special safety features to avoid deadlocks.
When used correctly (no nesting lock access functions), deadlocks should be impossible.
Implementations§
Source§impl<T> Slock<T>
impl<T> Slock<T>
Sourcepub async fn map<F, U>(&self, mapper: F) -> Result<U, Elapsed>
pub async fn map<F, U>(&self, mapper: F) -> Result<U, Elapsed>
Extract inner values from within a Slock
let name = lock.map(|v| v.name).await;
Sourcepub async fn set<F>(&self, setter: F)where
F: FnOnce(T) -> T,
pub async fn set<F>(&self, setter: F)where
F: FnOnce(T) -> T,
A setter for changing the internal data of the lock.
let lock = Slock::new(1i32);
lock.set(|v| v + 1).await;
lock.set(|_| 6).await;
Source§impl<T: Clone> Slock<T>
impl<T: Clone> Slock<T>
Sourcepub async fn clone_deep(&self) -> Self
pub async fn clone_deep(&self) -> Self
Create a new lock with data clone from this one.
Trait Implementations§
impl<T: Send> Send for Slock<T>
impl<T: Send> Sync for Slock<T>
Auto Trait Implementations§
impl<T> Freeze for Slock<T>
impl<T> !RefUnwindSafe for Slock<T>
impl<T> Unpin for Slock<T>
impl<T> !UnwindSafe for Slock<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