[−][src]Crate async_wg
async-wg
Async version WaitGroup for RUST.
Examples
#[tokio::main] async fn main() { use async_wg::WaitGroup; // Create a new wait group. let wg = WaitGroup::new(); for _ in 0..10 { let wg = wg.clone(); // Add count n. wg.add(1).await; tokio::spawn(async move { // Do some work. // Done count 1. wg.done().await; }); } // Wait for done count is equal to add count. wg.await; }
Benchmarks
Simple benchmark comparison run on github actions.
Code: benchs/main.rs
test bench_join_handle ... bench: 34,485 ns/iter (+/- 18,969)
test bench_wait_group ... bench: 36,916 ns/iter (+/- 7,555)
License
The Unlicense.
Structs
WaitGroup | Enables multiple tasks to synchronize the beginning or end of some computation. |