Expand description
Fluent spawn surface over the object-safe Runtime. Carries the axis
combinations the trait’s named methods pre-combine.
Fluent surface over Runtime, carrying the combinations the trait’s
named methods pre-combine.
Runtime is consumed as Arc<dyn Runtime> (App::offline_runtime, the
recording spigot), so it must stay object-safe: no generics, no RPITIT, and
every payload boxed. That erasure is real on the trait and needless at the
call site — this trait is never used as dyn itself, so it may carry
generics, and the boxing happens once inside it. Every method here stays
callable through a trait object: no Self: Sized bounds, and the blanket
impl is ?Sized, so Arc<dyn Runtime> reaches the whole builder.
Three independent axes the named methods weld together:
| axis | choices |
|---|---|
| placement | current core (default) / chosen core / background pool |
| payload | future / blocking closure |
| failure | SpawnError on a chosen core |
spawn_on_current_core binds placement and drops the Result;
spawn_factory_on_core binds placement and payload in one identifier. The
grid has more cells than there are names for, and this is where the rest of
them live.
rt.spawn(fut); // current core
rt.core(id).spawn(fut)?; // chosen core, SpawnError surfaced
rt.blocking(work).spawn().await?; // background pool, typed R back
rt.core([1, 2, 3]).spawn_with(|| work(), |_, e| *e == SpawnError::InboxFull)?;
// -> Ok(CoreId) which core took it, or Err(Exhausted { attempts, last })text, not a doctest: every line needs a live Runtime. A doctest that
cannot run is worse than prose — ignore compiles nothing while
cargo test --doc still exits 0, which is how a broken example ships. The
executable form of all four lines is in this module’s tests.
Structs§
- Blocking
- Payload bound to thread-occupying work.
- Exhausted
- Every candidate was tried and none accepted — the sequence’s own
termination signal, kept out of
SpawnErrorbecause that type answers for one core and its implementors produce only its two arms. Followingfan_in’s convention: termination lives in theErrchannel as a distinct value, not as a domain error reused to mean something else. - OnCore
- Placement bound. Every stage is complete on its own — the default it replaces is a real value, not an absent one.
Enums§
- Placement
- Which core, stated as intent rather than as an index the caller computed.
Traits§
- Runtime
Ext - Fluent spawn surface. Blanket-implemented for every
Runtime; never used asdynitself, which is what buys back the generics.