4 releases (2 breaking)
0.3.0 | Feb 21, 2024 |
---|---|
0.2.0 | Jul 25, 2022 |
0.1.1 | Mar 9, 2020 |
0.1.0 | Dec 6, 2018 |
#205 in Concurrency
19,475 downloads per month
Used in 27 crates
(14 directly)
20KB
297 lines
atomic_enum
An attribute to create an atomic wrapper around a C-style enum.
Internally, the generated wrapper uses an AtomicUsize
to store the value.
The atomic operations have the same semantics as the equivalent operations
of AtomicUsize
.
Example
# use atomic_enum::atomic_enum;
# use std::sync::atomic::Ordering;
#[atomic_enum]
#[derive(PartialEq)]
enum CatState {
Dead = 0,
BothDeadAndAlive,
Alive,
}
let state = AtomicCatState::new(CatState::Dead);
state.store(CatState::Alive, Ordering::Relaxed);
assert_eq!(state.load(Ordering::Relaxed), CatState::Alive);
This attribute does not use or generate any unsafe code.
The crate can be used in a #[no_std]
environment.
Maintenance Note
This crate is passively maintained.
Dependencies
~245–700KB
~17K SLoC