Crate lock_free_static

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§

lock_free_static
Convenience macro for creating lock-free statics.

Structs§

LockFreeStatic
Convenience wrapper for static initialization of cells.
Mutex
Lock-free mutex.
MutexGuard
Mutex lock guard.
OnceCell
Lock-free thread-safe cell which can be written to only once.
OnceMut
Like OnceCell but with exclusive mutable access to its content.

Type Aliases§

LockGuard
OnceMut lock guard.