Executor

Struct Executor 

Source
pub struct Executor<'a, const LEN: usize>
where Const<LEN>: Internal,
{ source: Pin<&'a Source>, shared: &'static ExecutorShared<LEN>, futures: [Pin<&'a mut (dyn Future<Output = Infallible> + 'a)>; LEN], }
Expand description

Async sub-executor.

This sub-executor does not handle the main loop of waiting till a waker is woken and then polling the futures, it expects to be run as a task within an executor that does that (e.g. futures::executor::block_on, wasm_bindgen_futures::spawn_local, veecle_freertos_integration::task::block_on_future). Within that outer executor loop this sub-executor tracks which of its futures were the cause of a wake and polls only them.

Being designed like this allows this sub-executor to be agnostic to how a platform actually runs futures—including esoteric platforms like wasm32-web which cannot have a thread-park based executor—while still giving the required guarantees about when and how the sub-futures are polled.

§Polling strategy

The executor polls all woken futures in a fixed order. The order corresponds to the order of the elements provided to Executor::new(). Initially, every future will be polled once.

§Background

Any write to a slot should be visible for every reader. To ensure this, every future waiting for a reader must be polled before the writer is polled again. With in-order polling, this is straight-forward to guarantee, as every future that is woken by a write will be polled before the writer is polled again.

Fields§

§source: Pin<&'a Source>

A generational source provided by the datastore.

§shared: &'static ExecutorShared<LEN>§futures: [Pin<&'a mut (dyn Future<Output = Infallible> + 'a)>; LEN]

Implementations§

Source§

impl<'a, const LEN: usize> Executor<'a, LEN>
where Const<LEN>: Internal,

Source

pub fn new( shared: &'static ExecutorShared<LEN>, source: Pin<&'a Source>, futures: [Pin<&'a mut (dyn Future<Output = Infallible> + 'a)>; LEN], ) -> Self

Creates a new Executor from the provided futures.

Source

pub(crate) fn run_once(&mut self) -> bool

Polls all woken futures once, returns true if at least one future was woken.

Source

pub async fn run(self) -> !

Runs all futures in an endless loop.

Trait Implementations§

Source§

impl<const LEN: usize> Debug for Executor<'_, LEN>
where Const<LEN>: Internal,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, const LEN: usize> Freeze for Executor<'a, LEN>

§

impl<'a, const LEN: usize> !RefUnwindSafe for Executor<'a, LEN>

§

impl<'a, const LEN: usize> !Send for Executor<'a, LEN>

§

impl<'a, const LEN: usize> !Sync for Executor<'a, LEN>

§

impl<'a, const LEN: usize> Unpin for Executor<'a, LEN>

§

impl<'a, const LEN: usize> !UnwindSafe for Executor<'a, LEN>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V