Struct lock_api::RawReentrantMutex
source · pub struct RawReentrantMutex<R, G> { /* private fields */ }
Expand description
A raw mutex type that wraps another raw mutex to provide reentrancy.
Although this has the same methods as the RawMutex
trait, it does
not implement it, and should not be used in the same way, since this
mutex can successfully acquire a lock multiple times in the same thread.
Only use this when you know you want a raw mutex that can be locked
reentrantly; you probably want ReentrantMutex
instead.
Implementations§
source§impl<R: RawMutex, G: GetThreadId> RawReentrantMutex<R, G>
impl<R: RawMutex, G: GetThreadId> RawReentrantMutex<R, G>
sourcepub fn try_lock(&self) -> bool
pub fn try_lock(&self) -> bool
Attempts to acquire this mutex without blocking. Returns true
if the lock was successfully acquired and false
otherwise.
sourcepub unsafe fn unlock(&self)
pub unsafe fn unlock(&self)
Unlocks this mutex. The inner mutex may not be unlocked if this mutex was acquired previously in the current thread.
Safety
This method may only be called if the mutex is held by the current thread.
sourcepub fn is_owned_by_current_thread(&self) -> bool
pub fn is_owned_by_current_thread(&self) -> bool
Checks whether the mutex is currently held by the current thread.
source§impl<R: RawMutexFair, G: GetThreadId> RawReentrantMutex<R, G>
impl<R: RawMutexFair, G: GetThreadId> RawReentrantMutex<R, G>
sourcepub unsafe fn unlock_fair(&self)
pub unsafe fn unlock_fair(&self)
Unlocks this mutex using a fair unlock protocol. The inner mutex may not be unlocked if this mutex was acquired previously in the current thread.
Safety
This method may only be called if the mutex is held by the current thread.
sourcepub unsafe fn bump(&self)
pub unsafe fn bump(&self)
Temporarily yields the mutex to a waiting thread if there is one.
This method is functionally equivalent to calling unlock_fair
followed
by lock
, however it can be much more efficient in the case where there
are no waiting threads.
Safety
This method may only be called if the mutex is held by the current thread.
source§impl<R: RawMutexTimed, G: GetThreadId> RawReentrantMutex<R, G>
impl<R: RawMutexTimed, G: GetThreadId> RawReentrantMutex<R, G>
sourcepub fn try_lock_until(&self, timeout: R::Instant) -> bool
pub fn try_lock_until(&self, timeout: R::Instant) -> bool
Attempts to acquire this lock until a timeout is reached.
sourcepub fn try_lock_for(&self, timeout: R::Duration) -> bool
pub fn try_lock_for(&self, timeout: R::Duration) -> bool
Attempts to acquire this lock until a timeout is reached.