3 个版本
0.1.2 | 2020年10月8日 |
---|---|
0.1.1 | 2020年4月14日 |
0.1.0 | 2020年2月28日 |
#627 在 异步
47,168 次每月下载
用于 86 个 crate(直接使用 11 个)
7KB
75 行
waitgroup
WaitGroup 等待一组任务完成。
示例
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;
}
许可证
本项目受 Apache License 2.0 许可(LICENSE)许可。
lib.rs
:
WaitGroup 等待一组任务完成。
示例
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;
}
依赖
~21KB