Debian Codegraph @

debian/rust-vendor/radium/README.md

raw
1 # radium
2
3 [![Latest Version][version_img]][crate_link]
4 [![Documentation][docs_img]][docs_link]
5
6 `radium` provides abstractions and graceful degradation for behavior that *must*
7 be shared-mutable, but merely *may* use atomic instructions to do so.
8
9 The primary export is the [`Radium`] trait. This is implemented on all symbols
10 in the [`atomic`] module, and on their [`Cell<T>`] equivalents, and presents the
11 atomic inherent API as a trait. Your code can be generic over `Radium`, use a
12 stable and consistent API, and permit callers to select atomic or `Cell`
13 behavior as they need.
14
15 The symbols in the [`atomic`] module are conditionally present according to the
16 target architecture’s atomic support. As such, code that is portable across
17 targets with varying atomic support cannot use those names directly. Instead,
18 the [`radium::types`] module provides names that will always exist, and forward
19 to the corresponding atomic type when it exists and the equivalent [`Cell<T>`]
20 type when it does not.
21
22 As the `cfg(target_has_atomic)` compiler attribute is unstable, `radium`
23 provides the macro `radium::if_atomic!` to perform conditional compilation based
24 on atomic availability.
25
26 This crate is `#![no_std]`-compatible, and uses no non-core types.
27
28 ## Versioning
29
30 Each change of supported target architecture will result in a new minor version.
31 Furthermore, `radium` is by definition attached to the Rust standard library.
32 As the atomic API evolves, `radium` will follow it. MSRV raising is always at
33 least a minor-version increase.
34
35 If you require a backport of architecture discovery to older Rust versions,
36 please file an issue. We will happily backport upon request, but we do not
37 proactively guarantee support for compilers older than ~six months.
38
39 ## Target Architecture Compatibility
40
41 Because the compiler does not expose this information to libraries, `radium`
42 uses a build script to detect the target architecture and emit its own
43 directives that mark the presence or absence of an atomic integer. We accomplish
44 this by reading the compiler’s target information records and copying the
45 information directly into the build script.
46
47 If `radium` does not work for your architecture, please update the build script
48 to handle your target string and submit a pull request. We write the build
49 script on an as-needed basis; it is not proactively filled with all of the
50 information listed in the compiler.
51
52 **NOTE**: The build script receives information through two variables: `TARGET`
53 and `CARGO_CFG_TARGET_ARCH`. The latter is equivalent to the value in
54 `cfg!(target_arch =)`; however, this value **does not** contain enough
55 information to fully disambiguate the target. The build script attempts to do
56 rudimentary parsing of the `env!(TARGET)` string; if this does not work for your
57 target, consider using the `TARGET_ARCH` matcher, or match on the full `TARGET`
58 string rather than the parse attempt.
59
60 ---
61
62 **@kneecaw** - <https://twitter.com/kneecaw/status/1132695060812849154>
63 > Feelin' lazy: Has someone already written a helper trait abstracting
64 > operations over `AtomicUsize` and `Cell<usize>` for generic code which may
65 > not care about atomicity?
66
67 **@ManishEarth** - <https://twitter.com/ManishEarth/status/1132706585300496384>
68 > no but call the crate radium
69 >
70 > (since people didn't care that it was radioactive and used it in everything)
71
72 <!-- Badges -->
73 [crate_link]: https://crates.io/crates/raidum "Crates.io package"
74 [docs_img]: https://docs.rs/radium/badge.svg "Radium documentation badge"
75 [docs_link]: https://docs.rs/radium "Radium documentation"
76 [version_img]: https://img.shields.io/crates/v/radium.svg "Radium version badge"
77 [`Cell<T>`]: https://doc.rust-lang.org/core/cell/struct.Cell.html
78 [`Radium`]: https://docs.rs/radium/latest/radium/trait.Radium.html
79 [`atomic`]: https://doc.rust-lang.org/core/sync/atomic
80 [`radium::types`]: https://docs.rs/radium/latest/radium/types