#[clippy::has_significant_drop]
#[must_use]
#[derive(Debug)]
pub struct DisabledPreemptGuard {
_private: (),
}
impl !Send for DisabledPreemptGuard {}
impl DisabledPreemptGuard {
fn new() -> Self {
super::cpu_local::inc_guard_count();
Self { _private: () }
}
pub fn transfer_to(&self) -> Self {
disable_preempt()
}
}
impl Drop for DisabledPreemptGuard {
fn drop(&mut self) {
super::cpu_local::dec_guard_count();
}
}
pub fn disable_preempt() -> DisabledPreemptGuard {
DisabledPreemptGuard::new()
}