Crates.io | atomic_float |
lib.rs | atomic_float |
version | 1.1.0 |
source | src |
created_at | 2020-09-14 20:19:42.529513 |
updated_at | 2024-08-31 18:44:38.287792 |
description | Floating point types which can be safely shared between threads |
homepage | https://github.com/thomcc/atomic_float |
repository | https://github.com/thomcc/atomic_float |
max_upload_size | |
id | 288706 |
size | 82,715 |
atomic_float
This crate provides AtomicF32
and AtomicF64
types that behave almost identically to the integer atomics in the stdlib.
use atomic_float::AtomicF32;
use core::sync::atomic::Ordering::Relaxed;
static A_STATIC: AtomicF32 = AtomicF32::new(800.0);
// Should support the full std::sync::atomic::AtomicFoo API
A_STATIC.fetch_add(30.0, Relaxed);
A_STATIC.fetch_sub(-55.0, Relaxed);
// But also supports things that can be implemented
// efficiently easily, like sign-bit operations.
A_STATIC.fetch_neg(Relaxed);
assert_eq!(A_STATIC.load(Relaxed), -885.0);
Licensed under either of
at your option.