set_timeout
This crate allows executing futures after a certain delay, similar to how setTimeout works in
js. The scheduling of a future can be cancelled as long as the future wasn't already executed,
by using a CancellationToken.
This crate uses a scheduler which allows running an unlimited number of delayed futures using
just a single tokio task, in contrast to many crates which spawn a new task for each set
timeout call. This uses less memory and should be more performant.
Please note that this crate can only by used in the context of a tokio runtime.
Example
async
Sharing The Scheduler
The timeout scheduler can be shared between multiple tasks, by storing it in an Arc, or by
storing it in a global variable using the lazy_static crate. For an example of this, check
out the example called global_variable in the examples directory.