pub fn without_interrupts<F, R>(f: F) -> R
where F: FnOnce() -> R,
Available on crate feature instructions only.
Expand description

Run a closure with disabled interrupts.

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

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

§Examples

// interrupts are enabled
without_interrupts(|| {
    // interrupts are disabled
    without_interrupts(|| {
        // interrupts are disabled
    });
    // interrupts are still disabled
});
// interrupts are enabled again