Skip to main content

PriorityMutex

Struct PriorityMutex 

Source
pub struct PriorityMutex<T> { /* private fields */ }
Expand description

A mutex that applies priority inheritance to its holder while higher-priority tasks are waiting on it.

#[repr(C)]: the fault-isolation path (poison_mutex) casts a type-erased pointer to PriorityMutex<()>, so the leading-field layout must be identical across monomorphizations.

Implementations§

Source§

impl<T> PriorityMutex<T>

Source

pub const fn new(value: T) -> Self

Source

pub fn is_poisoned(&self) -> bool

Whether this mutex has been poisoned by a faulting holder.

Source

pub fn try_lock(&self) -> Option<PriorityMutexGuard<'_, T>>

Non-blocking acquire. Returns None if the mutex is held (by anyone, including this task).

Source

pub fn lock(&self) -> PriorityMutexGuard<'_, T>

Acquire the mutex, blocking (yielding the CPU to other preemptive tasks — not busy-spinning) while it’s held elsewhere. Applies priority inheritance to the current holder for as long as this task waits.

§Panics

Panics if called outside of a preemptive task context, if the calling task already holds this mutex (recursive lock), or if the task already holds tcb::MAX_HELD mutexes.

Source

pub fn lock_timeout( &self, timeout: Option<Duration>, ) -> Result<PriorityMutexGuard<'_, T>, LockError>

Acquire the mutex with a deadline. Returns LockError::Timeout if the mutex is not acquired within timeout; None waits forever.

Trait Implementations§

Auto Trait Implementations§

§

impl<T> !Freeze for PriorityMutex<T>

§

impl<T> !RefUnwindSafe for PriorityMutex<T>

§

impl<T> Send for PriorityMutex<T>
where T: Send,

§

impl<T> Unpin for PriorityMutex<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for PriorityMutex<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for PriorityMutex<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.