tokio-tree-context
Similar to tokio-context, but support multiple level context
Why?
You can use it as a context that can cancel as if it is a normal context.
You can spawn child context from it, where child context is a context, and cancelling context also cancels all child contexts. And if child context has other contexts, they are cancelled too.
Imagine you want to allow an API to spawn new tasks by giving them a context. Then on timeout of the task, you want to cancel that context and all new tasks started by it, you can use this context.
Usage
Example
let mut ctx = new;
let mut ctx1 = ctx.new_child_context;
let mut ctx12 = ctx1.new_child_context;
ctx.spawn;
ctx1.spawn;
ctx12.spawn;
println!;
drop;
sleep.await;
println!;
drop;
sleep.await;
println!;
drop;
sleep.await;