Struct parking_lot::ArcMutexGuard
source · pub struct ArcMutexGuard<R, T>{ /* private fields */ }
Expand description
An RAII mutex guard returned by the Arc
locking operations on Mutex
.
This is similar to the MutexGuard
struct, except instead of using a reference to unlock the Mutex
it
uses an Arc<Mutex>
. This has several advantages, most notably that it has an 'static
lifetime.
Implementations§
source§impl<R, T> ArcMutexGuard<R, T>
impl<R, T> ArcMutexGuard<R, T>
sourcepub fn mutex(s: &ArcMutexGuard<R, T>) -> &Arc<Mutex<R, T>>
pub fn mutex(s: &ArcMutexGuard<R, T>) -> &Arc<Mutex<R, T>>
Returns a reference to the Mutex
this is guarding, contained in its Arc
.
sourcepub fn into_arc(s: ArcMutexGuard<R, T>) -> Arc<Mutex<R, T>>
pub fn into_arc(s: ArcMutexGuard<R, T>) -> Arc<Mutex<R, T>>
Unlocks the mutex and returns the Arc
that was held by the ArcMutexGuard
.
sourcepub fn unlocked<F, U>(s: &mut ArcMutexGuard<R, T>, f: F) -> Uwhere
F: FnOnce() -> U,
pub fn unlocked<F, U>(s: &mut ArcMutexGuard<R, T>, f: F) -> Uwhere
F: FnOnce() -> U,
Temporarily unlocks the mutex to execute the given function.
This is safe because &mut
guarantees that there exist no other
references to the data protected by the mutex.
source§impl<R, T> ArcMutexGuard<R, T>where
R: RawMutexFair,
T: ?Sized,
impl<R, T> ArcMutexGuard<R, T>where
R: RawMutexFair,
T: ?Sized,
sourcepub fn unlock_fair(s: ArcMutexGuard<R, T>)
pub fn unlock_fair(s: ArcMutexGuard<R, T>)
Unlocks the mutex using a fair unlock protocol.
This is functionally identical to the unlock_fair
method on MutexGuard
.
sourcepub fn unlocked_fair<F, U>(s: &mut ArcMutexGuard<R, T>, f: F) -> Uwhere
F: FnOnce() -> U,
pub fn unlocked_fair<F, U>(s: &mut ArcMutexGuard<R, T>, f: F) -> Uwhere
F: FnOnce() -> U,
Temporarily unlocks the mutex to execute the given function.
This is functionally identical to the unlocked_fair
method on MutexGuard
.
sourcepub fn bump(s: &mut ArcMutexGuard<R, T>)
pub fn bump(s: &mut ArcMutexGuard<R, T>)
Temporarily yields the mutex to a waiting thread if there is one.
This is functionally identical to the bump
method on MutexGuard
.