Crate lock_free_static

source ·
Expand description

Examples

Static variable

lock_free_static!{
    static VAR: i32 = 123;
}

fn main() {
    assert!(VAR.init());
    assert_eq!(*VAR.get().unwrap(), 123);
}

Mutable static variable

lock_free_static!{
    static mut VAR: i32 = 123;
}

fn main() {
    assert!(VAR.init());

    let mut guard = VAR.lock().unwrap();
    assert_eq!(*guard, 123);
    *guard = 321;
    drop(guard);

    assert_eq!(*VAR.lock().unwrap(), 321);
}

Macros

Structs

Type Aliases