Open link2xt opened 10 months ago
@link2txt, the interface is the same as std::time::Instant
so client code could use it as a replacement to implement suspend-aware timers in best effort manner.
I've decided to create this crate to support boot time in the completion-style IO driver.
But it's used only for Windows (IOCP) and BSD-like targets (kqueue). Linux implementation (io_uring) sets the native CLOCK_BOOTTIME flag for Timeout
op and relies on kernel-side high resolution timers.
To answer the question whether this crate solves potential users problem - it depends on the used OS primitives.
For Linux and io_uring there is no problem at all. For other platforms this crate could be used as a fallback.
Is there a way for this crate to be "dropped in" into Tokio's sleep function (as well as other functions) without forking Tokio?
I tried to pass this crate's implementation of Duration
to Tokio, but that didn't work.
Note: here is my code https://github.com/redlib-org/redlib/pull/23
Support of suspend-aware timers depends not on this crate but on used system interfaces. Tokio uses Mio as IO backend. Mio doesn't use IOCP on Windows nor Timeout operation on Linux+io_uring.
As I mentioned earlier this crate is not needed on Linux/io_uring
when kernel side timers are used. I've used this crate in application-side timer wheel for IOCP/kqueue backends.
This crate allows to measure time, but can it be used as a replacement for std clocks to create timers? E.g. as suggested in https://github.com/tokio-rs/tokio/issues/3185
I think it is not possible, but would be nice to get a confirmation. To close the issue I suggest writing this in the README so potential users know whether this crate solves their problem or not.