#counter #atomic #order #integer #width

no-std width_counters

Atomic counters with variable bit widths and customizable atomic ordering

9 releases (stable)

2.0.2 May 9, 2024
2.0.1 Jun 12, 2023
1.0.3 May 13, 2023
0.1.11 May 12, 2023

#661 in Rust patterns

Download history 6/week @ 2024-09-19 5/week @ 2024-09-26 2/week @ 2024-10-03

611 downloads per month

MIT/Apache

47KB
848 lines

width_counters

Usability:

License: MIT OR Apache-2.0 crates.io docs.rs

Development:

Maintenance: actively-developed GitHub Actions: CI


Overview

Atomic, thread-safe counters of differing integer widths

Comes with

These counters support

  • Incrementing/decrementing by default (1) or specified amounts,
  • Using per-operation atomic orderings, (see this also)
  • Instantiation with default offset (0) and default atomic ordering ( sequentially consistent ),
  • Instantiation with custom offset, custom ordering or both,
  • Instantiation with custom enum-flag-based counting behaviors (monotonic, nonmonotonic, incrementing, decrementing, cyclic, acyclic)
  • PartialEq, Eq, Hash, PartialOrd, Ord, Clone, Debug, Display
  • Send, Sync

Optional features

  • serde: Enable de/serialization

Dependencies

~2MB
~47K SLoC