Trait r3::kernel::mutex::MutexMethods

source ·
pub trait MutexMethods: MutexHandle {
    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

Get a flag indicating whether the mutex is currently locked.

Unlock the mutex.

Mutexes must be unlocked in a lock-reverse order, or this method may return UnlockMutexError::BadObjectState.

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).

lock with timeout.

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.

Mark the state protected by the mutex as consistent.

Relation to Other Specifications: Equivalent to pthread_mutex_consistent from POSIX.1-2008.

Implementors