pub struct Executor { /* private fields */ }
Expand description
Raw executor.
This is the core of the Embassy executor. It is low-level, requiring manual handling of wakeups and task polling. If you can, prefer using one of the higher level executors.
The raw executor leaves it up to you to handle wakeups and scheduling:
- To get the executor to do work, call
poll()
. This will poll all queued tasks (all tasks that “want to run”). - You must supply a
Pender
. The executor will call it to notify you it has work to do. You must arrange forpoll()
to be called as soon as possible.
The Pender
can be called from any context: any thread, any interrupt priority
level, etc. It may be called synchronously from any Executor
method call as well.
You must deal with this correctly.
In particular, you must NOT call poll
directly from the pender callback, as this violates
the requirement for poll
to not be called reentrantly.
Implementations§
Source§impl Executor
impl Executor
Sourcepub unsafe fn poll(&'static self)
pub unsafe fn poll(&'static self)
Poll all queued tasks in this executor.
This loops over all tasks that are queued to be polled (i.e. they’re freshly spawned or they’ve been woken). Other tasks are not polled.
You must call poll
after receiving a call to the Pender
. It is OK
to call poll
even when not requested by the Pender
, but it wastes
energy.
§Safety
You must NOT call poll
reentrantly on the same executor.
In particular, note that poll
may call the Pender
synchronously. Therefore, you
must NOT directly call poll()
from the Pender
callback. Instead, the callback has to
somehow schedule for poll()
to be called later, at a time you know for sure there’s
no poll()
already running.