tokio-async-utils 0.1.3

Async utils such as TaskHandle type that aborts task on handle drop.
Documentation
  • Coverage
  • 50%
    3 out of 6 items documented0 out of 0 items with examples
  • Size
  • Source code size: 12.46 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.49 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 19s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nxy7

Async Utils

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.

Provided types

  • TaskHandle - wrapper around JoinHandle, that can be obtained by calling to_task_handle() on tokio::task::JoinHandle. Aborts inner task on Drop.
  • TaskSet - alias for Tokio JoinSet. Tokio JoinSet already aborts tasks on Drop.
  • TaskMap - wrapper around HashMap<K, TaskHandle>. Useful if you want more control over your 'Set' of tasks as it makes it easier to see if there is already some task spawned.

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.