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
impl<R, G> RawReentrantMutex<R, G> where
R: RawMutex,
G: GetThreadId,
impl<R, G> RawReentrantMutex<R, G> where
R: RawMutex,
G: GetThreadId,
pub const INIT: RawReentrantMutex<R, G> = RawReentrantMutex{owner: AtomicUsize::new(0),
lock_count: Cell::new(0),
mutex: R::INIT,
get_thread_id: G::INIT,}
pub const INIT: RawReentrantMutex<R, G> = RawReentrantMutex{owner: AtomicUsize::new(0), lock_count: Cell::new(0), mutex: R::INIT, get_thread_id: G::INIT,}
Initial value for an unlocked mutex.
pub fn lock(&self)
pub fn lock(&self)
Acquires this mutex, blocking if it’s held by another thread.
pub 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.
pub 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.
pub 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.
impl<R, G> RawReentrantMutex<R, G> where
R: RawMutexFair,
G: GetThreadId,
impl<R, G> RawReentrantMutex<R, G> where
R: RawMutexFair,
G: GetThreadId,
pub 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.
pub 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.
impl<R, G> RawReentrantMutex<R, G> where
R: RawMutexTimed,
G: GetThreadId,
impl<R, G> RawReentrantMutex<R, G> where
R: RawMutexTimed,
G: GetThreadId,
pub fn try_lock_until(&self, timeout: <R as RawMutexTimed>::Instant) -> bool
pub fn try_lock_until(&self, timeout: <R as RawMutexTimed>::Instant) -> bool
Attempts to acquire this lock until a timeout is reached.
pub fn try_lock_for(&self, timeout: <R as RawMutexTimed>::Duration) -> bool
pub fn try_lock_for(&self, timeout: <R as RawMutexTimed>::Duration) -> bool
Attempts to acquire this lock until a timeout is reached.
Trait Implementations
impl<R, G> Send for RawReentrantMutex<R, G> where
R: RawMutex + Send,
G: GetThreadId + Send,
impl<R, G> Sync for RawReentrantMutex<R, G> where
R: RawMutex + Sync,
G: GetThreadId + Sync,
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more