context-async
This lib provide an trait Context
and a Timer
to control async function.
It's based on tokio
.
Usage
Add this lib as dependencies in Cargo.toml
.
[]
= { = "*" }
In your code, you can simple use Timer
:
use time;
use ;
async
async
Timer
and Context
implements Clone
, which creates a new Context
(same as itself).
Timer
and Context
can spawn children contexts, and ensure the following conditions are met:
- The life cycle of the child context will not exceed the parent context;
- If the parent context is cancelled, all child contexts will be cancelled.
- The cancellation of the child context will be chained to all child contexts, but will not affect the parent context.
for more information, see examples or visit the documentation.