Skip to main content

Module delay

Module delay 

Source
Expand description

embedded-hal-async::delay::DelayNs on top of the preemptive tier’s blocking sleep (plan.md Phase 15).

This is a blocking implementation of an async trait — deliberately. Rivet’s preemptive tier has no “suspend this task, return control to an executor” primitive the way the cooperative tier’s Sleep does (that one needs a compile-time duration, Sleep<const MICROS: u64>, which doesn’t fit DelayNs’s runtime-parameterized signature); what a preemptive task actually does to give up the CPU for a while is block (rivet::preempt::sleep_ms) — the scheduler runs something else in the meantime, which is the same practical effect .awaiting a real async delay would have. A driver written against DelayNs works correctly called from a preemptive task; it just isn’t meaningful to call from the cooperative executor’s own task (blocking there would stall every other cooperative task, exactly as blocking always would).

Structs§

RivetDelay