tokio-inherit-task-local
Provides functionality very similar to tokio::task_local
with one key difference. Any future annotated with
.inherit_task_local()
will inherit the task local values of the task which spawned it. This does not inherit
values created by tokio::task_local
, it will only inherit values created by inheritable_task_local
.
Here's a simple example
use ;
inheritable_task_local!
async
Even though DEMO_VALUE
was not defined for the spawned future, it was still able to inherit the value defined in
its parent. This happens thanks to the .inherit_task_local()
method call. That method can be found in
FutureInheritTaskLocal
.
These inherited values DO NOT need to be Clone
. Child tasks will inherit counted references to the original value.