Skip to main content

Module time

Module time 

Source
Expand description

View-thread async timers — sleep, interval, timeout.

All three integrate with the Scheduler’s timer registry. Zero threads spawned, zero extra allocations beyond the sorted registry entry.

§How the registry drives everything

Sleep/Interval/Timeout::poll()     Scheduler::tick()
──────────────────────────────     ──────────────────────────────────────
register(deadline, waker) ───────► fire_expired()
                                       deadline ≤ now?
                                         yes → waker.wake()
                                              → executor marks task woken
                                              → next poll → Poll::Ready

                                   calculate_park_timeout()
                                     includes next timer deadline
                                     → thread parks exactly until expiry

Structs§

Elapsed
Error returned when a timeout expires before the wrapped future.
Interval
A periodic timer. Each call to tick() returns a future that resolves at the next scheduled instant.
Sleep
A future that completes after a given duration.
Timeout
Wraps a future and cancels it if it does not complete within duration.

Functions§

interval
Create a periodic timer that fires every period.
sleep
Suspend the current task for duration without blocking the view thread.
timeout
Run future, but give up and return Elapsed after duration.