| Crates.io | taskwait |
| lib.rs | taskwait |
| version | 0.4.1 |
| created_at | 2021-03-13 10:47:01.906053+00 |
| updated_at | 2021-03-19 18:18:43.711017+00 |
| description | Runtime agnostic way to wait for a group of async tasks |
| homepage | https://github.com/staticgc/taskwait |
| repository | https://github.com/staticgc/taskwait |
| max_upload_size | |
| id | 368250 |
| size | 14,637 |
Runtime agnostic way of waiting for async tasks.
WaitGroup.Add & WaitGroup.Donedone()ing the task i.e. calling done() on drop.add, done and RAII semantics.use taskwait::TaskGroup;
let tg = TaskGroup::();
for _ in 0..10 {
tg.add();
let tg_c = tg.clone();
tokio::spawn(async move{
...
tg_c.done();
})
}
tg.wait().await;
use taskwait::TaskGroup;
let tg = TaskGroup::();
for _ in 0..10 {
let work = tg.add_work(1); // Increment counter
tokio::spawn(async move{
let _work = work; // done() will be called when this is dropped
...
})
}
tg.wait().await;