#delay #sleep #interval #timeout #async

timer-kit

A timer toolkit that is generic over the underlying timer implementation

2 releases

0.1.1 Feb 2, 2023
0.1.0 Feb 1, 2023

#541 in WebAssembly

Download history 441/week @ 2024-07-20 493/week @ 2024-07-27 396/week @ 2024-08-03 284/week @ 2024-08-10 446/week @ 2024-08-17 383/week @ 2024-08-24 693/week @ 2024-08-31 370/week @ 2024-09-07 498/week @ 2024-09-14 548/week @ 2024-09-21 877/week @ 2024-09-28 624/week @ 2024-10-05 1026/week @ 2024-10-12 627/week @ 2024-10-19 739/week @ 2024-10-26 834/week @ 2024-11-02

3,299 downloads per month
Used in 2 crates

MIT/Apache

93KB
1.5K SLoC

timer-kit

A timer toolkit that is generic over the underlying timer implementation.

crate_version docs_version

This crate does not implement any platform-specific timer but uses a generic abstraction over the timer implementation to provide a set of timer related tools:

  1. [sleep()]/Sleep
  2. [timeout()]/Timeout
  3. [interval()]/Interval
  4. DelayQueue

This crate currently does not provide any feature beyond the ones that is already provided by tokio, so this crate is completely not needed if you are already using tokio in your project.

The core of this crate is the Delay trait, and it is implemented for the following types by enabling the corresponding features:

Type Feature Target Arch
tokio::time::Sleep "tokio" non-wasm32
smol::Timer "smol" non-wasm32
futures_timer::Delay "futures-timer" non-wasm32
wasm_timer::Delay "wasm-timer" wasm32
fluvio_wasm_timer::Delay "fluvio-wasm-timer" wasm32

WebAssembly support

Support for wasm32-unknown-unknown target depends on the chosen timer implementation. wasm-timer and fluvio-wasm-timer are the only two wasm timer implementations that are currently supported.

Examples

The usage remains mostly similar to those provided in tokio::time with one additional generic type parameter D which is the type of the underlying timer implementation. Please refer to the documentation of the corresponding types for more details.

License: MIT/Apache-2.0

Dependencies

~0.8–13MB
~174K SLoC