#atomic #float #floating-point #atomicf32

无需 std atomic_float

可以在线程间安全共享的浮点类型

2 个版本 (1 个稳定版)

1.0.0 2024 年 5 月 4 日
0.1.0 2020 年 9 月 14 日

#39并发

Download history 14658/week @ 2024-04-26 13286/week @ 2024-05-03 16122/week @ 2024-05-10 13601/week @ 2024-05-17 12810/week @ 2024-05-24 13806/week @ 2024-05-31 15329/week @ 2024-06-07 15139/week @ 2024-06-14 16031/week @ 2024-06-21 10986/week @ 2024-06-28 12083/week @ 2024-07-05 11784/week @ 2024-07-12 13748/week @ 2024-07-19 13592/week @ 2024-07-26 10565/week @ 2024-08-02 10703/week @ 2024-08-09

51,066 每月下载量
用于 305 个 Crates (21 个直接使用)

Apache-2.0 OR MIT OR Unlicense

68KB
394

atomic_float

Build Status codecov Docs Latest Version

此 crate 提供 AtomicF32AtomicF64 类型,其行为几乎与 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);

许可证

许可协议为以下之一

任选其一。

依赖项

~165KB