Skip to main content

SpawnerSlot

Struct SpawnerSlot 

Source
pub struct SpawnerSlot { /* private fields */ }
Expand description

A runtime-filled slot holding the SendSpawner of an executor other than the one the supervisor runs on — an InterruptExecutor tier, the second core’s executor, any foreign thread executor (via Spawner::make_send()).

Declared by the executor NAME; item of supervisor_graph!; nodes carrying executor: NAME are spawned through the slot instead of the supervisor’s own Spawner. The application fills it once at startup — before, or concurrently with, Supervisor::start (e.g. from the second core’s bring-up):

static EXECUTOR_HIGH: InterruptExecutor = InterruptExecutor::new();
HIGH.set(EXECUTOR_HIGH.start(interrupt::SWI_IRQ_0));
sup.start(spawner).await?;   // nodes declared `executor: HIGH` spawn on that tier

The supervisor’s bring-up (start / start_node / respawn_terminate) awaits ready for a node’s slot before spawning it, so a tier filled late — or from another core — is handled without a race; a slot still empty after the supervisor’s bounded wait fails the spawn with SpawnError::Busy rather than silently dropping the task. Spawned futures must be Send (a non-Send executor: task is a compile error at the glue).

Implementations§

Source§

impl SpawnerSlot

Source

pub const fn new() -> Self

An empty slot (const — it lives in a static the macro emits).

Source

pub fn set(&self, spawner: SendSpawner)

Fill the slot (last set wins) and wake a ready waiter. Call before Supervisor::start — or from the other core’s bring-up, with the supervisor awaiting ready().

Source

pub fn get(&self) -> Option<SendSpawner>

The registered spawner, or None while unfilled.

Source

pub async fn ready(&self) -> SendSpawner

Await the slot and return the spawner. The rendezvous primitive: the supervisor’s bring-up awaits this for a node’s executor: slot before spawning it (bounded, see Supervisor::start), so a tier filled late — or from another core — is handled without a race. Returns immediately once the slot is filled, so any number of late callers are fine (an application can gate work on the executor being up). While the slot is still empty, at most one task should be parked here: the underlying Signal holds a single waker, so a second pre-fill waiter would displace the first.

Trait Implementations§

Source§

impl Default for SpawnerSlot

Source§

fn default() -> Self

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

Auto Trait Implementations§

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.