Macro kernel::init_static_sync
source · [−]macro_rules! init_static_sync {
($($(#[$outer:meta])* $v:vis static $id:ident : $t:ty $(= $value:expr)?;)*) => { ... };
(@call_new $t:ty, $value:expr) => { ... };
(@call_new $t:ty,) => { ... };
}
Expand description
Automatically initialises static instances of synchronisation primitives.
The syntax resembles that of regular static variables, except that the value assigned is that
of the protected type (if one exists). In the examples below, all primitives except for
CondVar
require the inner value to be supplied.
Examples
ⓘ
struct Test {
a: u32,
b: u32,
}
init_static_sync! {
static A: Mutex<Test> = Test { a: 10, b: 20 };
/// Documentation for `B`.
pub static B: Mutex<u32> = 0;
pub(crate) static C: SpinLock<Test> = Test { a: 10, b: 20 };
static D: CondVar;
static E: RevocableMutex<Test> = Test { a: 30, b: 40 };
}