Skip to main content

IrqDisabledToken

Struct IrqDisabledToken 

Source
pub struct IrqDisabledToken(());
Expand description

Typed proof that IRQs are masked on the current CPU.

The memory allocator consumes this token to prevent, at compile time, calls from contexts where an interrupt could re-enter the same lock and cause a deadlock.

Intentionally non-Copy and non-Clone: the token must not escape the IRQ-off context in which it was created.

§Creation paths

PathVisibilityUse case
verify()pubCheck RFLAGS; returns Some if IRQs already disabled
with_irqs_disabled()pubSafe wrapper: disables IRQs, runs closure, restores
IrqDisabled::enter()pub(super)Guardian: called by SpinLock on acquire
token_from_trusted_context()pub(crate)Trait impls (e.g. X86FrameAllocator) that can’t accept a token parameter
new_unchecked()pub(super)Internal to sync module only; never call directly

Tuple Fields§

§0: ()

Implementations§

Source§

impl IrqDisabledToken

Source

pub fn verify() -> Option<Self>

Check the current interrupt state and return proof if IRQs are already disabled.

Source

pub(super) unsafe fn new_unchecked() -> Self

Build the proof without re-checking RFLAGS.

Restricted to pub(super): only visible within the sync module. External code must use verify(), with_irqs_disabled(), or token_from_trusted_context() instead.

§Safety

The caller must guarantee that IRQs are indeed disabled on the current CPU for the entire logical validity of the token.

Source

pub(crate) unsafe fn token_from_trusted_context() -> Self

Create a token when the caller guarantees that IRQs are already disabled.

Purpose: Implementing external traits (e.g. X86FrameAllocator) whose signature cannot accept a token parameter.

§Safety

The caller must guarantee that IRQs are disabled on the current CPU. This is a pub(crate) escape hatch : prefer verify() or with_irqs_disabled() for all other use cases.

Trait Implementations§

Source§

impl Debug for IrqDisabledToken

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.