raii-counter
Rust type for a RAII Counter (counts number of held instances,
decrements count on Drop
), implemented with Arc<AtomicUsize>
.
Useful for tracking the number of holders exist for a handle, tracking the number of transactions that are in-flight, etc.
Additional Features
- Counters can have a size, eg. a Counter with
size
4 adds 4 to the count, and removes 4 when dropped.
Demo
extern crate raii_counter;
use Counter;
let counter = new;
assert_eq!;
let weak = counter.downgrade;
assert_eq!;
assert_eq!;
License: MIT