#atomic #float #thread #atomicf32 #atomic-f32

no-std atomic_float

Floating point types which can be safely shared between threads

3 releases (stable)

1.1.0 Aug 31, 2024
1.0.0 May 4, 2024
0.1.0 Sep 14, 2020

#26 in Concurrency

Download history 27147/week @ 2025-01-28 24117/week @ 2025-02-04 29093/week @ 2025-02-11 33438/week @ 2025-02-18 37399/week @ 2025-02-25 33397/week @ 2025-03-04 33030/week @ 2025-03-11 32524/week @ 2025-03-18 98582/week @ 2025-03-25 418554/week @ 2025-04-01 349475/week @ 2025-04-08 173213/week @ 2025-04-15 173002/week @ 2025-04-22 134445/week @ 2025-04-29 177255/week @ 2025-05-06 154435/week @ 2025-05-13

668,340 downloads per month
Used in 381 crates (38 directly)

Apache-2.0 OR MIT OR Unlicense

67KB
386 lines

atomic_float

Build Status codecov Docs Latest Version

This crate provides AtomicF32 and AtomicF64 types that behave almost identically to the integer atomics in the stdlib.

Usage

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);

License

Licensed under either of

at your option.

Dependencies

~150KB

OSZAR »