Struct AllocExecutor

Source
pub struct AllocExecutor<'a, R, S>
where R: RawMutex,
{ /* private fields */ }
Expand description

Alloc-only Future executor

Assuming the RawMutex implementation provided is sound, this should be safe to use in both embedded and non-embedded scenarios. On embedded devices, it will probably be a type that disables/re-enables interrupts. On real OS’s, it can be an actual mutex implementation.

The Sleep implementation can be used to put the event loop into a low-power state using something like cortex_m::wfi/e.

Implementations§

Source§

impl<'a, R, S> AllocExecutor<'a, R, S>
where R: RawMutex, S: Sleep + Wake + Clone + Default,

Source

pub fn new() -> Self

Initialize a new AllocExecutor

Does nothing unless it’s run()

Source

pub fn with_capacity(registry: usize, queue: usize) -> Self

Initialize a new AllocExecutor with the given capacities.

Does nothing unless it’s run()

Source

pub fn spawner(&self) -> Spawner<'a, R>

Get a handle to a Spawner that can be passed to Future constructors to spawn even more Futures

Source

pub fn local_spawner(&self) -> LocalSpawner<'a, R>

Get a handle to a LocalSpawner that can be passed to local Future constructors to spawn even more local Futures

Source

pub fn spawn_raw<F>(&mut self, future: F)
where F: UnsafeFutureObj<'a, ()>,

Spawn a local UnsafeFutureObj into the executor.

Source

pub fn spawn<F>(&mut self, future: F)
where F: Future<Output = ()> + 'a,

Spawn a Future into the executor.

This will implicitly box the future in order to objectify it.

Source

pub fn run(&mut self)

Run the executor

Each loop will poll at most one task from the queue and then check for newly spawned tasks. If there are no new tasks spawned and nothing left in the queue, the executor will attempt to sleep.

Once there’s nothing to spawn and nothing left in the registry, the executor will return.

Trait Implementations§

Source§

impl<'a, R, S> Default for AllocExecutor<'a, R, S>
where R: RawMutex, S: Sleep + Wake + Clone + Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, R, S> Freeze for AllocExecutor<'a, R, S>
where S: Freeze,

§

impl<'a, R, S> !RefUnwindSafe for AllocExecutor<'a, R, S>

§

impl<'a, R, S> !Send for AllocExecutor<'a, R, S>

§

impl<'a, R, S> !Sync for AllocExecutor<'a, R, S>

§

impl<'a, R, S> Unpin for AllocExecutor<'a, R, S>
where S: Unpin,

§

impl<'a, R, S> !UnwindSafe for AllocExecutor<'a, R, S>

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, 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.