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§
- Lock
Free Static - Convenience wrapper for static initialization of cells.
- Mutex
- Lock-free mutex.
- Mutex
Guard Mutexlock guard.- Once
Cell - Lock-free thread-safe cell which can be written to only once.
- OnceMut
- Like
OnceCellbut with exclusive mutable access to its content.