Crates.io | tokio-async-utils |
lib.rs | tokio-async-utils |
version | 0.1.3 |
source | src |
created_at | 2024-03-05 20:08:30.489952 |
updated_at | 2024-03-05 20:31:41.190736 |
description | Async utils such as TaskHandle type that aborts task on handle drop. |
homepage | |
repository | https://github.com/nxy7/async-utils |
max_upload_size | |
id | 1163953 |
size | 11,175 |
Simple crate created out of need to manage my Tokio JoinHandles. Async runtimes get to decide how they treat spawned tasks and Tokio went with the model that detaches spawned Tasks. Regardless of the fact if You think that's good choice, to avoid leaking tasks and for easier task management it's useful to have tasks 'attached' to some handle and cancel them on handle drop. This makes structured concurrency much easier, as you don't have to manually send values down some channels and instead you just need to make sure that parent task is holding TaskHandle of child and doesn't drop it. That's where this crate is primarily coming from. Right now it provides 3 (actually 2) structs to help to manage concurrency.
to_task_handle()
on tokio::task::JoinHandle. Aborts inner task on Drop.All those types abort tasks when they are dropped. In the future I might put here more 'async' utilities that I find useful in my every day coding.