tokio-tree-context 0.1.5

Tokio Context for launching and cancelling tasks
Documentation
  • Coverage
  • 87.5%
    7 out of 8 items documented3 out of 7 items with examples
  • Size
  • Source code size: 26.02 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.47 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 25s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • wushilin/tokio-tree-context
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wushilin

tokio-tree-context

Similar to tokio-context, but support multiple level context

Usage

Example

        let mut ctx = tokio_tree_context::Context::new();

        let mut ctx1 = ctx.new_child_context();
        let mut ctx12 = ctx1.new_child_context();

        ctx.spawn(async move {
            sleep("ctx".into(), 100).await;
        });
        ctx1.spawn(async move {
            sleep("ctx1".into(), 100).await;
        });
        ctx12.spawn(async move {
            sleep("ctx12".into(), 100).await;
        });
        println!("Cancelling CTX 1");
        drop(ctx1);
        sleep("main".into(), 5).await;
        println!("Cancelling CTX 12");
        drop(ctx12);
        sleep("main".into(), 5).await;

        println!("Cancelling CTX");
        drop(ctx);

        sleep("main".into(), 5).await;