Skip to content

Add RealtimeDelay for realtime clock support - #8

Open
saneki wants to merge 1 commit into
polachok:masterfrom
saneki:realtime
Open

Add RealtimeDelay for realtime clock support#8
saneki wants to merge 1 commit into
polachok:masterfrom
saneki:realtime

Conversation

@saneki

@saneki saneki commented Aug 6, 2026

Copy link
Copy Markdown

This adds RealtimeDelay for a oneshot timer operating on the realtime clock, which the timerfd crate provides support for. It is very similar to Delay but uses a SystemTime deadline and the Abstime flag when setting the timer.

Other notes:

  • Declined to implement RealtimeDelay::reset to discourage desyncing the struct state with the potentially armed timerfd state.
  • poll may return an io::Error of kind ErrorKind::Other if deadline is before the Unix epoch. Reaching this requires the system's realtime clock to also be before the epoch for at least a short period of time so it may be impossible for this to actually occur, but I figured returning an Err was better than a panic.

Very similar to `Delay` but uses a realtime clock with a provided `SystemTime` deadline and the `Abstime` flag when setting the timer.

Other notes:
- Declined to implement `RealtimeDelay::reset` to discourage desyncing the struct state with the potentially armed `timerfd` state.
- `poll` may return an `io::Error` of kind `ErrorKind::Other` if `deadline` is before the Unix epoch. Reaching this requires the system's realtime clock to also be before the epoch for at least a short period of time so it may be impossible for this to actually occur, but I figured returning an `Err` was better than a panic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant