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

Demo

```rust extern crate raiicounter; use raiicounter::Counter;

let counter = Counter::new(); assert_eq!(counter.count(), 1);

let weak = counter.downgrade(); assert_eq!(weak.count(), 0);

{ let counter1 = weak.spawnupgrade(); asserteq!(weak.count(), 1); let _counter2 = weak.spawnupgrade(); assert_eq!(weak.count(), 2); }

assert_eq!(weak.count(), 0); ```

License: MIT