Trait r3_core::kernel::mutex::MutexMethods
source · pub trait MutexMethods: MutexHandle {
// Provided methods
fn is_locked(&self) -> Result<bool, QueryMutexError> { ... }
fn unlock(&self) -> Result<(), UnlockMutexError> { ... }
fn lock(&self) -> Result<(), LockMutexError> { ... }
fn lock_timeout(
&self,
timeout: Duration
) -> Result<(), LockMutexTimeoutError> { ... }
fn try_lock(&self) -> Result<(), TryLockMutexError> { ... }
fn mark_consistent(&self) -> Result<(), MarkConsistentMutexError> { ... }
}
Expand description
The supported operations on MutexHandle
.
Provided Methods§
sourcefn is_locked(&self) -> Result<bool, QueryMutexError>
fn is_locked(&self) -> Result<bool, QueryMutexError>
Get a flag indicating whether the mutex is currently locked.
sourcefn unlock(&self) -> Result<(), UnlockMutexError>
fn unlock(&self) -> Result<(), UnlockMutexError>
Unlock the mutex.
Mutexes must be unlocked in a lock-reverse order, or this method may
return UnlockMutexError::BadObjectState
.
sourcefn lock(&self) -> Result<(), LockMutexError>
fn lock(&self) -> Result<(), LockMutexError>
Acquire the mutex, blocking the current thread until it is able to do so.
An abandoned mutex can still be locked, but this method will return
Err(Abandoned)
. Note that the current task will receive the
ownership of the mutex even in this case.
This system service may block. Therefore, calling this method is not
allowed in a non-waitable context and will return Err(BadContext)
.
sourcefn lock_timeout(&self, timeout: Duration) -> Result<(), LockMutexTimeoutError>
fn lock_timeout(&self, timeout: Duration) -> Result<(), LockMutexTimeoutError>
lock
with timeout.
sourcefn try_lock(&self) -> Result<(), TryLockMutexError>
fn try_lock(&self) -> Result<(), TryLockMutexError>
Non-blocking version of lock
. Returns
immediately with TryLockMutexError::Timeout
if the unblocking
condition is not satisfied.
Note that unlike Semaphore::poll_one
, this operation is disallowed
in a non-task context because a mutex lock needs an owning task.
sourcefn mark_consistent(&self) -> Result<(), MarkConsistentMutexError>
fn mark_consistent(&self) -> Result<(), MarkConsistentMutexError>
Mark the state protected by the mutex as consistent.
Relation to Other Specifications: Equivalent to
pthread_mutex_consistent
from POSIX.1-2008.