Struct holochain::prelude::dependencies::kitsune_p2p_types::dependencies::lair_keystore_api::dependencies::parking_lot::lock_api::RawReentrantMutex
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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.