Crates.io | wag |
lib.rs | wag |
version | 0.3.0 |
source | src |
created_at | 2022-12-04 19:03:03.80239 |
updated_at | 2022-12-05 18:49:17.66502 |
description | Go like sync.WaitGroup implementation in Rust. (sync/async) |
homepage | https://github.com/just-do-halee/wag |
repository | https://github.com/just-do-halee/wag.git |
max_upload_size | |
id | 729707 |
size | 19,999 |
WAG
Go like sync.WaitGroup implementation in Rust. (sync/async)
| Examples | Docs | Latest Note |
wag = "0.3.0"
How to use,
use wag::WaitGroup;
let wg = WaitGroup::new();
for _ in 0..10 {
let w = wg.add();
thread::spawn(move || {
// ...
w.done();
});
});
wg.wait(); // or wg.async_wait().await;
for w in wg.adds::<10>() {
thread::spawn(move || {
// ...
w.done();
});
});
wg.wait(); // or wg.async_wait().await;
let [w1, w2, w3] = wg.adds();
thread::spawn(move || {
// ...
w1.done();
});
thread::spawn(move || {
// ...
w2.done();
});
thread::spawn(move || {
// ...
w3.done();
});
wg.wait(); // or wg.async_wait().await;
wg.adds_iter::<10>().enumerate().for_each(|(i, w)| {
thread::spawn(move || {
// ... with i
w.done();
});
});
wg.wait(); // or wg.async_wait().await;