#atomic #traits #extension #sync

no-std atomex

Atomics extensions in Rust

1 unstable release

0.1.0 Oct 9, 2024

#843 in Algorithms

Download history 160/week @ 2024-10-07 41/week @ 2024-10-14 10/week @ 2024-10-21 10/week @ 2024-10-28 35/week @ 2024-11-04

102 downloads per month
Used in 7 crates (via abs_sync)

MIT/Apache

33KB
809 lines

atomex

Some useful extensions around Atomic* in core::sync::atomic.

This crate is mainly inspired by atomic-traits

Example

use core::sync::atomic::*;
use atomex::AtomicCount;

let atm = AtomicUsize::new(0usize);
let cnt = AtomicCount::<usize, AtomicUsize>::new(atm);

let mut atm = cnt.into_inner();
let cnt = AtomicCount::<usize, &mut AtomicUsize>::new(&mut atm);

assert_eq!(cnt.inc(), 0usize);
assert_eq!(cnt.dec(), 1usize);
assert_eq!(cnt.val(), 0usize);

Dependencies

~81KB