Skip to main content

InAtomicMode

Trait InAtomicMode 

Source
pub unsafe trait InAtomicMode: Debug { }
Expand description

A marker trait for guard types that enforce the atomic mode.

Key kernel primitives such as SpinLock and Rcu rely on the atomic mode for correctness or soundness. The existence of such a guard guarantees that the current task is executing in the atomic mode.

It requires [core::fmt::Debug] by default to make it easier to derive [Debug] for types with &dyn InAtomicMode.

§Safety

The implementer must ensure that the atomic mode is maintained while the guard type is alive.

A guard is only valid evidence about the task that created it: it proves nothing about any other task. Therefore, such guards must be !Send and !Sync, so that the guards and their references are confined to the creating task.

Trait Implementations§

Source§

impl AsAtomicModeGuard for dyn InAtomicMode + '_

Source§

fn as_atomic_mode_guard(&self) -> &dyn InAtomicMode

Returns a guard for the atomic mode.
Source§

impl PinCurrentCpu for dyn InAtomicMode + '_

Source§

fn current_cpu(&self) -> CpuId

Returns the ID of the current CPU.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§