| Crates.io | taskmanager |
| lib.rs | taskmanager |
| version | 0.6.2 |
| created_at | 2023-05-12 01:14:45.388284+00 |
| updated_at | 2024-08-03 15:03:23.824303+00 |
| description | Manage groups of background tasks |
| homepage | |
| repository | https://github.com/andrewbaxter/taskmanager |
| max_upload_size | |
| id | 862613 |
| size | 14,573 |
This is a tool for managing asynchronous tasks.
For example, maybe you have some periodic background tasks, plus a couple web servers. Using a TaskManager you can group these and shut them down as a group, gracefully, and wait for them all to end.
Handles
Use it like
let tm = TaskManager::new();
tm.attach_sigint({
log2 = logger.clone();
|e| log2.err("Error handling sigint", e)
});
let tm1 = tm.clone();
let log2 = logger.clone();
tm.task(async move {
match tm1.if_alive(server).await {
Some(r) => match r {
Ok(_) => {} // Server exited normally
Err(e) => {
log.err("Server died with error", e);
}
},
None => {} // Received shutdown
};
});
tm.join().await;