Skip to main content

RawMutexTimed

Trait RawMutexTimed 

Source
pub unsafe trait RawMutexTimed: RawMutex {
    type Duration;
    type Instant;

    // Required methods
    fn try_lock_for(&self, timeout: Self::Duration) -> Option<Self::Guard>;
    fn try_lock_until(&self, timeout: Self::Instant) -> Option<Self::Guard>;
}
Expand description

Additional methods for mutexes which support locking with timeouts.

The Duration and Instant types are specified as associated types so that this trait is usable even in no_std environments.

§Safety

Implementations must uphold the safety requirements of RawMutex for the additional methods provided by this trait.

Required Associated Types§

Source

type Duration

Duration type used for try_lock_for.

Source

type Instant

Instant type used for try_lock_until.

Required Methods§

Source

fn try_lock_for(&self, timeout: Self::Duration) -> Option<Self::Guard>

Attempts to acquire this lock until a timeout is reached.

A successful operation may return early. An unsuccessful operation must not return before the timeout, but may return later due to scheduling or platform-specific behavior.

Source

fn try_lock_until(&self, timeout: Self::Instant) -> Option<Self::Guard>

Attempts to acquire this lock until a timeout is reached.

A successful operation may return early. An unsuccessful operation must not return before the timeout, but may return later due to scheduling or platform-specific behavior.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§