pub struct Executor<'a, const LEN: usize>{
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.
futures: [Pin<&'a mut (dyn Future<Output = Infallible> + 'a)>; LEN]Implementations§
Source§impl<'a, const LEN: usize> Executor<'a, LEN>
impl<'a, const LEN: usize> Executor<'a, LEN>
Sourcepub fn new(
shared: &'static ExecutorShared<LEN>,
source: Pin<&'a Source>,
futures: [Pin<&'a mut (dyn Future<Output = Infallible> + 'a)>; LEN],
) -> Self
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.