15 releases

0.5.0 Aug 6, 2020
0.4.6 Jul 5, 2020
0.4.5 May 16, 2019
0.4.4 Feb 22, 2019
0.3.0 Mar 30, 2016

#236 in Concurrency

Download history 11268/week @ 2020-12-25 13698/week @ 2021-01-01 14840/week @ 2021-01-08 14189/week @ 2021-01-15 14744/week @ 2021-01-22 13920/week @ 2021-01-29 15616/week @ 2021-02-05 16673/week @ 2021-02-12 17940/week @ 2021-02-19 20614/week @ 2021-02-26 19157/week @ 2021-03-05 22763/week @ 2021-03-12 19910/week @ 2021-03-19 20978/week @ 2021-03-26 18866/week @ 2021-04-02 17629/week @ 2021-04-09

62,784 downloads per month
Used in 202 crates (29 directly)

Apache-2.0/MIT

45KB
925 lines

Generic Atomic<T> for Rust

Build Status Crates.io

A Rust library which provides a generic Atomic<T> type for all T: Copy types, unlike the standard library which only provides a few fixed atomic types (AtomicBool, AtomicIsize, AtomicUsize, AtomicPtr).

This library will use native atomic instructions if possible, and will otherwise fall back to a lock-based mechanism. You can use the Atomic::<T>::is_lock_free() function to check whether native atomic operations are supported for a given type. Note that a type must have a power-of-2 size and alignment in order to be used by native atomic instructions.

This crate uses #![no_std] and only depends on libcore.

Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
atomic = "0.5"

and this to your crate root:

extern crate atomic;

To enable nightly-only features, add this to your Cargo.toml instead:

[dependencies]
atomic = {version = "0.5", features = ["nightly"]}

License

Licensed under either of

at your option.

Contribution

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.

No runtime deps