Diffinery

homeflare/celldpublic

celld/crates/logic/src/schedule.rs
31 lines · 1.5 KBRaw History
1//! Cell-isolate dispatch decisions, reified sans-IO. A cell isolate runs one
2//! event at a time. A top-level Worker fetch takes the resident-isolate fast
3//! path only when the isolate is idle; if the isolate is already pumping an
4//! actor event, the fetch must reschedule to the stateless Worker pool — never
5//! run nested — carrying its request identity so the reply still lands
6//! (`js.rs`, the fix the 256-ring warm lab forced). The executor and the
7//! production run loop hold the isolate channels and the pool; this is the pure
8//! routing they consult, and the DST drives it directly (`tests/dst`,
9//! `actor_call`). See `wiki/designs/dst-actor-call.md`.
10
11/// Where a top-level Worker fetch runs when it reaches a cell isolate.
12#[derive(Clone, Copy, Debug, PartialEq, Eq)]
13pub enum Route {
14 /// The isolate is idle: run the fetch on the resident isolate (fast path).
15 OnIsolate,
16 /// The isolate is pumping an actor event: hand the fetch to the stateless
17 /// Worker pool with its request identity preserved. A Worker event never
18 /// runs nested in an isolate already running an actor event.
19 RescheduleToPool,
20}
21
22/// Route a top-level Worker fetch reaching a cell isolate. The load-bearing
23/// invariant: a Worker event must never execute nested in an isolate already
24/// pumping an actor event, so a busy isolate always reschedules to the pool.
25pub fn route_worker_fetch(isolate_active: bool) -> Route {
26 if isolate_active {
27 Route::RescheduleToPool
28 } else {
29 Route::OnIsolate
30 }
31}