#atomic #cell #sync #generic #trait

no-std radium

Portable interfaces for maybe-atomic types

12 unstable releases (5 breaking)

0.6.2 Jan 25, 2021
0.6.1 Nov 21, 2020
0.6.0 Oct 26, 2020
0.3.0 Jan 6, 2020
0.1.1 May 26, 2019

#30 in Concurrency

Download history 59991/week @ 2021-01-13 68900/week @ 2021-01-20 75256/week @ 2021-01-27 79728/week @ 2021-02-03 92661/week @ 2021-02-10 109673/week @ 2021-02-17 112687/week @ 2021-02-24 110150/week @ 2021-03-03 107880/week @ 2021-03-10 104405/week @ 2021-03-17 109979/week @ 2021-03-24 97997/week @ 2021-03-31 114212/week @ 2021-04-07 115220/week @ 2021-04-14 112474/week @ 2021-04-21 92386/week @ 2021-04-28

310,811 downloads per month
Used in 1,027 crates (2 directly)

MIT license

650 lines


Latest Version Documentation

radium provides abstractions and graceful degradation for behavior that must be shared-mutable, but merely may use atomic instructions to do so.

The primary export is the Radium trait. This is implemented on all symbols in the atomic module, and on their Cell<T> equivalents, and presents the atomic inherent API as a trait. Your code can be generic over Radium, use a stable and consistent API, and permit callers to select atomic or Cell behavior as they need.

The symbols in the atomic module are conditionally present according to the target architecture’s atomic support. As such, code that is portable across targets with varying atomic support cannot use those names directly. Instead, the radium::types module provides names that will always exist, and forward to the corresponding atomic type when it exists and the equivalent Cell<T> type when it does not.

As the cfg(target_has_atomic) compiler attribute is unstable, radium provides the macro radium::if_atomic! to perform conditional compilation based on atomic availability.

This crate is #![no_std]-compatible, and uses no non-core types.

Target Architecture Compatibility

Because the compiler does not expose this information to libraries, radium uses a build script to detect the target architecture and emit its own directives that mark the presence or absence of an atomic integer. We accomplish this by reading the compiler’s target information records and copying the information directly into the build script.

If radium does not work for your architecture, please update the build script to handle your target string and submit a pull request. We write the build script on an as-needed basis; it is not proactively filled with all of the information listed in the compiler.

@kneecaw - https://twitter.com/kneecaw/status/1132695060812849154

Feelin' lazy: Has someone already written a helper trait abstracting operations over AtomicUsize and Cell<usize> for generic code which may not care about atomicity?

@ManishEarth - https://twitter.com/ManishEarth/status/1132706585300496384

no but call the crate radium

(since people didn't care that it was radioactive and used it in everything)

No runtime deps