pub struct RecursiveMutex { /* private fields */ }Expand description
RAII wrapper around a recursive mutex.
Implementations§
Source§impl RecursiveMutex
impl RecursiveMutex
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new recursive mutex via heap allocation (only in heap mode).
Sourcepub fn create(storage: &'static RecursiveMutexStorage) -> Result<Self>
pub fn create(storage: &'static RecursiveMutexStorage) -> Result<Self>
Mode-agnostic constructor (see Mutex::create).
Sourcepub fn lock(&self) -> Result<RecursiveMutexGuard<'_>>
pub fn lock(&self) -> Result<RecursiveMutexGuard<'_>>
Acquire the recursive mutex, blocking indefinitely. Returns an RAII guard that releases one level of the lock on drop. Same thread may call this multiple times — each guard releases one level when dropped.
Sourcepub fn try_lock(&self) -> Result<RecursiveMutexGuard<'_>>
pub fn try_lock(&self) -> Result<RecursiveMutexGuard<'_>>
Attempt to acquire the recursive mutex without blocking.
§Errors
Returns Error::WouldBlock if held by a different thread.
Sourcepub fn try_lock_for(&self, d: Duration) -> Result<RecursiveMutexGuard<'_>>
pub fn try_lock_for(&self, d: Duration) -> Result<RecursiveMutexGuard<'_>>
Attempt to acquire the recursive mutex, waiting up to d.
Sourcepub fn try_lock_until(
&self,
deadline: Instant,
) -> Result<RecursiveMutexGuard<'_>>
pub fn try_lock_until( &self, deadline: Instant, ) -> Result<RecursiveMutexGuard<'_>>
Attempt to acquire the recursive mutex by the given deadline.
Use Instant::FOREVER for an
indefinite wait.
Sourcepub fn unlock(&self)
pub fn unlock(&self)
Release one level of the recursive lock.
Prefer letting the RAII guard (RecursiveMutexGuard) drop
release the lock; this is kept pub for parity with the C API.