docs/generated/contracts.mdgenerated from code
Reference · 2 min read
scheduler
Contracts: scheduler.
Read as
Source: crates/lvcs-runtime/src/scheduler.rs.
1/// A tree of machines that run together: a cap on how many of them step at2/// once, the scopes it is nested in, and the pending count it shares with3/// its root.4#[derive(Clone)]5pub struct TokioScope {6 /// The scope's shared state.7 inner: Arc<ScopeInner>,8}910/// sml's scheduler slot for a machine run on its own Tokio task in a11/// [`TokioScope`]. Built by [`TokioScope::scheduler`].12pub struct TokioScheduler<E, O, C = ()> {13 /// The machine's step slot.14 slot: Slot<E, O, C>,15 /// The scope it runs in.16 scope: TokioScope,17 /// A scope the machine owns: it ends when the machine stops.18 owns: Option<TokioScope>,19 /// Its steps run on Tokio's blocking pool, not on its task.20 blocking: bool,21 /// The journal tail it replays while it is built.22 rebuild: Option<Rebuild<E, O, C>>,23}2425/// A journal tail a machine replays while it is built: given a step of the26/// machine (`None` once it stopped), it says whether the machine reached27/// the journal's state.28type Rebuild<E, O, C> =29 Box<dyn FnOnce(&mut dyn FnMut(E) -> Option<Stepped<E, O, C>>) -> bool + Send>;3031/// The policy of a machine run on its own Tokio task in a scope: the32/// [`Trace`] logger, the growing defer queue ([`crate::Growing`],33/// session-9468d544/40), and the [`TokioScheduler`] (discussion:owner/40234/// and discussion:owner/403).35pub type Scheduled<E, O, C = ()> = sml::Policies<36 Trace,37 (),38 sml::JumpTable,39 (),40 (),41 crate::Growing,42 sml::DefaultQueuePolicy,43 TokioScheduler<E, O, C>,44>;4546/// Where a [`TokioScheduler`] machine's core lives, and the queue its task47/// reads. Every clone of the generated machine holds a clone of it.48pub struct TokioCell<M, E> {49 /// The generated machine's core.50 core: Arc<Mutex<M>>,51 /// The machine's queue. Each event waits there boxed, so the queue's52 /// first block, made with the machine, holds 32 pointers rather than 3253 /// events whatever the event type (f-break/14).54 events: mpsc::UnboundedSender<Box<Queued<E>>>,55 /// The pending counts of its scope and every scope it is made from,56 /// which each queued event counts toward.57 pending: Counts,58 /// The machine's kind, its queue depth's attribute.59 kind: ActorKind,60 /// What the watchdog reads of the machine's scheduler.61 watched: Arc<Watched>,62 /// Where an event submitted after its queue closed goes back.63 returns: Option<Hand<E>>,64}6566/// Counts one unit of work toward its scope's pending count, and every67/// count of the scopes it is made from up to the root's, until it is68/// dropped.69#[derive(Debug)]70pub struct Busy {71 /// The counts it counts toward.72 pending: Counts,73}7475/// Resolves to a queued event's acceptance once its step closed; `false`76/// when the machine had stopped or its scope ended before it ran.77#[derive(Debug)]78pub struct TokioCompletion {79 /// The machine's reply.80 reply: oneshot::Receiver<bool>,81}