Skip to main content

IrqMutex

Struct IrqMutex 

Source
pub struct IrqMutex<T> {
    data: UnsafeCell<T>,
    locked: AtomicBool,
}
Expand description

Spinlock for data shared between normal kernel code and interrupt handlers; disables interrupts while held to avoid self-deadlock.

Fields§

§data: UnsafeCell<T>§locked: AtomicBool

Implementations§

Source§

impl<T> IrqMutex<T>

Source

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

Create a new unlocked IrqMutex wrapping val.

Source

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

Acquire the lock, disabling interrupts first. Returns a guard that restores IF on drop.

Source

pub unsafe fn force_unlock(&self)

Release the lock without restoring the interrupt flag, for use in panic paths.

§Safety

Calling this while a live IrqMutexGuard still exists creates two concurrent accessors to the protected data. Only call from a panic handler that halts the CPU immediately after and never touches the data through the mutex again.

Trait Implementations§

Source§

impl<T: Send> Send for IrqMutex<T>

Source§

impl<T: Send> Sync for IrqMutex<T>

Auto Trait Implementations§

§

impl<T> !Freeze for IrqMutex<T>

§

impl<T> !RefUnwindSafe for IrqMutex<T>

§

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

§

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

§

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

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.