macro_rules! cpu_local { () => { ... }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => { ... }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => { ... }; }
Expand description
Defines a CPU-local variable.
§Example
use crate::cpu_local;
use core::cell::RefCell;
cpu_local! {
static FOO: RefCell<u32> = RefCell::new(1);
#[allow(unused)]
pub static BAR: RefCell<f32> = RefCell::new(1.0);
}
CpuLocal::borrow_with(&FOO, |val| {
println!("FOO VAL: {:?}", *val);
})