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 signal_fn. The executor will call it to notify you it has work to do. You must arrange for poll() to be called as soon as possible.

signal_fn 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 signal_fn, as this violates the requirement for poll to not be called reentrantly.

Implementations

Create a new executor.

When the executor has work to do, it will call signal_fn with signal_ctx as argument.

See Executor docs for details on signal_fn.

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 signal_fn. It is OK to call poll even when not requested by signal_fn, but it wastes energy.

Safety

You must NOT call poll reentrantly on the same executor.

In particular, note that poll may call signal_fn synchronously. Therefore, you must NOT directly call poll() from your signal_fn. Instead, signal_fn has to somehow schedule for poll() to be called later, at a time you know for sure there’s no poll() already running.

Get a spawner that spawns tasks in this executor.

It is OK to call this method multiple times to obtain multiple Spawners. You may also copy Spawners.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.