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
| Path | Visibility | Use case |
|---|---|---|
verify() | pub | Check RFLAGS; returns Some if IRQs already disabled |
with_irqs_disabled() | pub | Safe 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
impl IrqDisabledToken
Sourcepub fn verify() -> Option<Self>
pub fn verify() -> Option<Self>
Check the current interrupt state and return proof if IRQs are already disabled.
Sourcepub(super) unsafe fn new_unchecked() -> Self
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.
Sourcepub(crate) unsafe fn token_from_trusted_context() -> Self
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§
Auto Trait Implementations§
impl Freeze for IrqDisabledToken
impl RefUnwindSafe for IrqDisabledToken
impl Send for IrqDisabledToken
impl Sync for IrqDisabledToken
impl Unpin for IrqDisabledToken
impl UnsafeUnpin for IrqDisabledToken
impl UnwindSafe for IrqDisabledToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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