hal_core/
local.rs

1//! Abstractions for core-local storage.
2
3/// A core-local storage cell.
4///
5/// This trait represents an architecture-specific mechanism for storing local
6/// data for each CPU core.
7pub trait CoreLocal<T: 'static> {
8    /// Returns a new instance of `Self`, using the provided `init` function to
9    /// generate the initial value for each CPU core.
10    fn new(init: fn() -> T) -> Self;
11
12    /// Accesses the value for the current CPU core.
13    ///
14    /// This method invokes the provided closure `f` with a reference to the
15    /// `T`-typed local data for the current CPU core.
16    fn with<F, U>(&self, f: F) -> U
17    where
18        F: FnOnce(&T) -> U;
19}