#waitgroup #notify #wake #futures #async

waitgroup

Async waitgroup for a collection of task to finish

3 releases

0.1.2 Oct 8, 2020
0.1.1 Apr 14, 2020
0.1.0 Feb 28, 2020

#192 in Asynchronous

Download history 4/week @ 2020-10-30 27/week @ 2020-11-06 68/week @ 2020-11-13 45/week @ 2020-11-20 37/week @ 2020-11-27 8/week @ 2020-12-04 6/week @ 2020-12-11 8/week @ 2020-12-25 8/week @ 2021-01-01 1/week @ 2021-01-08 4/week @ 2021-01-15 7/week @ 2021-01-22 7/week @ 2021-01-29 37/week @ 2021-02-05 46/week @ 2021-02-12

167 downloads per month

Apache-2.0

7KB
75 lines

waitgroup

A WaitGroup waits for a collection of task to finish.

Examples

use waitgroup::WaitGroup;
use async_std::task;
async {
	let wg = WaitGroup::new();
	for _ in 0..100 {
		let w = wg.worker();
		task::spawn(async move {
			// do work
			drop(w); // drop w means task finished
		};
	}

	wg.wait().await;
}

License

This project is licensed under Apache License, Version 2.0 (LICENSE ).


lib.rs:

A WaitGroup waits for a collection of task to finish.

Examples

use waitgroup::WaitGroup;
use async_std::task;
# task::block_on(
async {
    let wg = WaitGroup::new();
    for _ in 0..100 {
        let w = wg.worker();
        task::spawn(async move {
            // do work
            drop(w); // drop w means task finished
        });
    }

    wg.wait().await;
}
# );

Dependencies

~19KB