#async-version #wait-group #async #future

yanked async-wg

Async version WaitGroup for RUST

0.1.2 Feb 18, 2020
0.1.1 Feb 8, 2020
0.1.0 Feb 6, 2020

#14 in #wait-group

Unlicense

8KB
109 lines

async-wg

Rustc Version Actions Crate API

Async version WaitGroup for RUST.

Installation

With cargo add installed run:

$ cargo add -s async-wg

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.

Dependencies

~715KB
~14K SLoC