Trait r3::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§

source

fn is_locked(&self) -> Result<bool, QueryMutexError>

Get a flag indicating whether the mutex is currently locked.

source

fn unlock(&self) -> Result<(), UnlockMutexError>

Unlock the mutex.

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

source

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

source

fn lock_timeout(&self, timeout: Duration) -> Result<(), LockMutexTimeoutError>

lock with timeout.

source

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.

source

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.

Implementors§

source§

impl<T> MutexMethods for Twhere T: MutexHandle,