2 个版本
使用旧的 Rust 2015
0.1.1 | 2016年4月11日 |
---|---|
0.1.0 | 2016年4月11日 |
#114 in #bits
10KB
257 行
Atomic64 - Rust 的 64 位整数原子操作
用法
atomic64
在 Crates.io 上。
要使用 atomic64
,首先将以下内容添加到你的 Cargo.toml
[dependencies]
atomic64 = "0.1.0"
然后,将以下内容添加到你的 crate 根目录
extern crate atomic64;
现在你可以使用 AtomicI64 和 AtomicU64。
## 注意
由于使用了 const fn
允许在常量上下文中创建 AtomicI64::new
和 AtomicU64::new
,因此 atomic64 仅可在 nightly rust 上使用。也许条件编译可以解决这个问题?
包括来自 Syncbox 的代码。
## 内部结构
在 64 位平台上,atomic64 将内部使用 Rust 的 AtomicIsize 和 AtomicUsize。
在 32 位平台上,atomic64 将使用由 Mutex 包裹的 i64 或 u64。32 位和 64 位平台之间的性能将会有很大差异,64 位平台预计将更快。