Struct r3::sync::recursive_mutex::GenericRecursiveMutex
source · pub struct GenericRecursiveMutex<Cell, Mutex> { /* private fields */ }
sync
only.Expand description
A recursive mutex, which can be locked by a task for multiple times without causing a deadlock.
This type is implemented using r3::kernel::Mutex
, the low-level
synchronization primitive and therefore inherits its properties.
The important inherited properties are listed below:
-
When trying to lock an abandoned mutex, the lock function will return
Err(LockError::Abandoned(lock_guard))
. This state can be exited by callingGenericRecursiveMutex::mark_consistent
. -
Mutexes must be unlocked in a lock-reverse order.
GenericMutexGuard
::drop
might panic if this is violated.
Example
See StaticRecursiveMutex
.
Implementations§
source§impl<System, T: 'static> GenericRecursiveMutex<Hunk<System, MaybeUninit<MutexInner<T>>>, MutexRef<'static, System>>where
System: KernelMutex + KernelStatic,
impl<System, T: 'static> GenericRecursiveMutex<Hunk<System, MaybeUninit<MutexInner<T>>>, MutexRef<'static, System>>where System: KernelMutex + KernelStatic,
sourcepub const fn define() -> Definer<System, DefaultSource<MutexInner<T>>>
pub const fn define() -> Definer<System, DefaultSource<MutexInner<T>>>
Construct a Definer
to define a mutex in a configuration
function.
source§impl<Cell, Mutex, T> GenericRecursiveMutex<Cell, Mutex>where
Cell: Deref<Target = MaybeUninit<MutexInner<T>>>,
Mutex: MutexHandle,
impl<Cell, Mutex, T> GenericRecursiveMutex<Cell, Mutex>where Cell: Deref<Target = MaybeUninit<MutexInner<T>>>, Mutex: MutexHandle,
sourcepub fn lock(&self) -> LockResult<GenericMutexGuard<'_, Cell, Mutex, T>>
pub fn lock(&self) -> LockResult<GenericMutexGuard<'_, Cell, Mutex, T>>
Acquire the mutex, blocking the current thread until it is able to do so.
Panics
This method will panic if the nesting count would overflow.
sourcepub fn try_lock(&self) -> TryLockResult<GenericMutexGuard<'_, Cell, Mutex, T>>
pub fn try_lock(&self) -> TryLockResult<GenericMutexGuard<'_, Cell, Mutex, T>>
sourcepub fn mark_consistent(&self) -> Result<(), MarkConsistentError>
pub fn mark_consistent(&self) -> Result<(), MarkConsistentError>
Mark the state protected by the mutex as consistent.