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
sourceimpl<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.
sourceimpl<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.
sourceimpl<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.
Trait Implementations
impl<R: RawMutex + Send, G: GetThreadId + Send> Send for RawReentrantMutex<R, G>
impl<R: RawMutex + Sync, G: GetThreadId + Sync> Sync for RawReentrantMutex<R, G>
Auto Trait Implementations
impl<R, G> !RefUnwindSafe for RawReentrantMutex<R, G>
impl<R, G> Unpin for RawReentrantMutex<R, G> where
G: Unpin,
R: Unpin,
impl<R, G> UnwindSafe for RawReentrantMutex<R, G> where
G: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more