pub struct Executor { /* private fields */ }Expand description
Thread-mode executor: runs tasks on the main context, and idles the
core in wfe when none are ready.
wfe parks the core until an event or an interrupt arrives, so an
idle program draws no more power than a wfi loop — unlike a spinning
executor. Interrupts wake it regardless of the event register, which
is what lets the timer interrupt drive embassy-time deadlines.
There is no lost-wake-up race between polling and sleeping. sev sets
a sticky per-core event register, so a wake-up that lands in the window
after the last poll and before the wfe makes that wfe return
immediately rather than sleeping through it.
Implementations§
Source§impl Executor
impl Executor
Sourcepub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> !
pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> !
Spawns the initial tasks and then runs them forever.
init receives a Spawner for this executor and is called once,
before the first poll; keep a copy of the Spawner (it is Copy)
to spawn more later from inside a task.
Never returns. Between polls the core sits in wfe, so anything
that should wake it — including the embassy-time deadline
interrupt — must be enabled before this is called.