Skip to content

Provide boottime timersΒ #3185

Open
Open
@mahkoh

Description

Is your feature request related to a problem? Please describe.

On linux, tokio currently delegates to std::sync::Condvar::wait_timeout and epoll_wait. These functions use CLOCK_MONOTONIC. Therefore, time spent in system sleep does not count towards tokio timers.

Sometimes you want to schedule an operation periodically. For example, poll an external resource once an hour. CLOCK_MONOTONIC is not suitable for this usecase. After the system wakes up from sleep, you most likely want to poll the external resource immediately if a wall clock hour has elapsed.

Describe the solution you'd like

Provide some way to create CLOCK_BOOTTIME timers.

Describe alternatives you've considered

This can be implemented as an external library. But tokio already contains the infrastructure to work with timers.

Additional context

I assume timeouts are also affected by sleep not counting towards them.

On Windows, std::sync::Condvar::wait_timeout behaves the same way. However, due to rust-lang/rust#79462, any spurious wakeup will cause the timer to expire.

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-feature-requestCategory: A feature request.M-timeModule: tokio/time

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions