Crates.io | lock-free-static |
lib.rs | lock-free-static |
version | 0.2.0 |
source | src |
created_at | 2023-10-02 03:39:08.145511 |
updated_at | 2023-10-26 08:38:06.550018 |
description | Lock-free static variables |
homepage | https://gitlab.com/agerasev/lock-free-static |
repository | https://gitlab.com/agerasev/lock-free-static.git |
max_upload_size | |
id | 989584 |
size | 32,903 |
Lock-free static variables.
use lock_free_static::lock_free_static;
lock_free_static!{
static VAR: i32 = 123;
}
fn main() {
assert!(VAR.init());
assert_eq!(*VAR.get().unwrap(), 123);
}
use lock_free_static::lock_free_static;
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);
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.