Fork of DarrenTsung's raii-counter library that allows you to wait asynchronously for the count to reach zero.
```rust use raiicounterfutures::WeakCounter; use std::time::Duration;
let weak = Arc::new(WeakCounter::new()); assert_eq!(counter.count(), 0);
let weak2 = Arc::clone(&weak); tokio::spawn(async move { let counter1 = weak2.spawnupgrade(); let counter2 = weak2.spawnupgrade();
tokio::time::delay_for(Duration::from_secs(2)).await;
});
// Give the weak counters a chance to spawn, in a real workload you would not // want to start waiting immediately after your async tasks spawn. tokio::time::delayfor(Duration::frommillis(500)).await;
// This will not complete until the 2 second delay in the async task has finished. counter.waitforempty().await; ```