Function without_interrupts

Source
pub fn without_interrupts<F, R>(f: F) -> R
where F: FnOnce() -> R,
Expand description

Run a closure with disabled interrupts.

Run the given closure, disabling interrupts before running it (if they aren’t already disabled). Afterward, interrupts are enabled again if they were enabled before.

If you have other enable and disable calls within the closure, things may not work as expected.

Only has an effect if target_os = "none".

§Examples

// interrupts may or may not be enabled
interrupts::without(|| {
    // interrupts are disabled
});
// interrupts are restored to the previous state

Nesting:

// interrupts may be enabled
interrupts::without(|| {
    // interrupts are disabled
    interrupts::without(|| {
        // interrupts are disabled
    });
    // interrupts are still disabled
});
// interrupts are restored