Portable atomic types.
Atomic{I,U}{8,16,32,64}
) for all targets that can use atomic CAS. (i.e., all targets that can use std
, and most no-std targets)Atomic{I,U}128
.AtomicF{32,64}
.
fallback
(enabled by default)
Enable fallback implementations.
i128
Provide Atomic{I,U}128
.
Note:
fallback
feature.cmpxchg16b
target feature is not enabled at compile time, this uses the fallback implementation. cmpxchg16b
is enabled by default only on macOS.The above status is likely to change in the future:
Atomic{I,U}128
is stabilized in the standard library.If you need support for dynamic CPU feature detection, use the i128-dynamic
feature.
i128-dynamic
Similar to the i128
feature, but tries to use cmpxchg16b
in more cases based on dynamic CPU feature detection.
Note:
i128
feature.cmpxchg16b
target feature is enabled at compile time, this works exactly the same as the i128
feature.i128
and i128-dynamic
features are used in the dependency graph, i128-dynamic
takes precedence.std
and parking_lot
).float
Provide AtomicF{32,64}
.
Note that most of fetch_*
operations of atomic floats are implemented using CAS loops, which can be slower than equivalent operations of atomic integers.
std
Use std
.
serde
Implement serde::{Serialize,Deserialize}
for atomic types.
Note:
parking_lot
Use [parking_lot] in global locks of fallback implementation.
Note:
--cfg portable_atomic_unsafe_assume_single_core
Assume that the target is single-core.
When this cfg is enabled, this crate provides atomic CAS for targets where atomic CAS is not available in the standard library.
Note: This cfg is unsafe
, and enabling this cfg for multi-core systems is unsound.
This is intentionally not an optional feature. If this is an optional feature, dependencies can implicitly enable the feature, resulting in the use of unsound code without the end-user being aware of it.
Licensed under either of Apache License, Version 2.0 or MIT license 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.