pub unsafe trait InterruptControl {
type State: Copy;
const INIT: Self::State;
// Required methods
fn disable() -> Self::State;
unsafe fn restore(state: Self::State);
}Expand description
Strategy for disabling and restoring local (per-CPU) interrupts.
Implement this trait to tell the allocator how to disabling interrupts around a lock’s critical section, so the locked allocators are safe to call from interrupt context.
disable must save the prior state and then
disable, returning that state; restore must put
it back. Saving the prior state (rather than unconditionally re-enabling) is
what makes nesting correct: an inner lock taken while an outer lock already
disabled interrupts will, on release, restore “still disabled”, and only the
outermost release re-enables.
§Safety
restore is unsafe: it changes the CPU interrupt-enable state and must be
called exactly once, with the State returned by the
matching disable, after the critical section. disable/restore need to be
faithful inverses.
Required Associated Constants§
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".