2 releases
0.1.1 | May 27, 2021 |
---|---|
0.1.0 | May 27, 2021 |
#925 in Asynchronous
10KB
178 lines
tokio-switching-sleep
A tokio Sleep with a switchable state.
lib.rs
:
This crate contains two objects: SwitchingSleep
and ASwitchingSleep
.
ASwitchingSleep
is just a wrapper around
Arc
<RwLock
<SwitchingSleep
>>.
They are a tokio::time::Sleep
with a
switchable state. When you call the start
method a Sleep
is created,
when you call the stop
one the current Sleep
is dropped. So calling
start
will reset the timer.
The timer will complete after the duration
time since
start
method is called (or new_start
, new
+ start
).
Dependencies
~2.2–8MB
~63K SLoC