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 expiryStructs§
- Elapsed
- Error returned when a
timeoutexpires 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.