Expand description
Cross-architecture utilities for temporarily disabling interrupts.
This crate allows you to temporarily disable interrupts and then restore the previous state again.
Supported architectures:
-
AArch64 (
arch = aarch64) -
64-bit RISC-V (
arch = riscv64) -
x86-64 (
arch = x86_64)
On other architectures, this crate does nothing.
§Caveats
Interrupts are disabled on a best-effort basis.
Even though this crate makes sure that interrupts are disabled, nothing prevents you from manually enabling them again.
Manually dropping Guards may also cause interrupts to be enabled.
§Examples
Use disable to disable interrupts with a guard:
// interrupts may or may not be enabled
let guard = interrupts::disable();
// interrupts are disabled
drop(guard);
// interrupts are restored to the previous stateUse without to run a closure with disabled interrupts:
// interrupts may or may not be enabled
interrupts::without(|| {
// interrupts are disabled
});
// interrupts are restored to the previous state§Related Crates
- interrupt-ref-cell (A
RefCellfor sharing data with interrupt handlers on the same thread.) - interrupt-mutex (A mutex for sharing data with interrupt handlers.)
Structs§
- Guard
- An interrupt guard.