Skip to main content

byteflow/scheduler/
mod.rs

1//! M:N **flows**, mailboxes, timer, supervisor and [`Runtime`].
2//!
3//! A **flow** is Byteflow's unit of concurrent work (not an OS thread). Flows
4//! exchange **Atomic Hops** ([`crate::Value::Message`]) — never bare scalars
5//! on bytecode `Send` / `Ask`.
6//!
7//! # Authority boundary
8//!
9//! The VM only validates types. This module owns delivery:
10//!
11//! 1. Resolve [`crate::Value::Cap`] → [`FlowId`] + rights ([`CapRights`])
12//! 2. Stamp `Message.sender` and mint `reply_cap` (SEND-only)
13//! 3. Push into the target [`Mailbox`] (bounded; anti lost-wakeup under one mutex)
14//!
15//! [`crate::Value::Pid`] is identity inside hops, not an ambient address.
16//! Host [`Runtime::send`] takes [`FlowId`] directly (trusted).
17//!
18//! See [`crate::docs::security`] and [`crate::docs::atomic_hop`].
19
20mod capability;
21mod directory;
22mod error;
23mod handle;
24mod mailbox;
25mod metrics;
26pub(crate) mod oneshot;
27mod process;
28mod runtime;
29mod supervisor;
30mod sync_lock;
31mod timer;
32mod worker;
33
34pub use capability::{CapId, CapRights};
35pub use error::{fault_count, report_fault, RuntimeError, SpawnError};
36pub use handle::FlowHandle;
37pub use mailbox::{
38    Delivery, Mailbox, MailboxCapacity, MailboxConfig, MailboxFull, MailboxStats, OverflowPolicy,
39};
40pub use metrics::{RuntimeMetrics, RuntimeMetricsSnapshot};
41pub use process::{
42    next_flow_id, Flow, FlowId, FlowMetrics, FlowOutcome, FlowState, RestartPolicy,
43};
44pub use runtime::{
45    flow_id_from_u64, Runtime, RuntimeConfig, RuntimeSpawner, SendError, DEFAULT_QUANTUM,
46};
47pub use supervisor::{ChildSpec, Supervisor, SupervisorConfig};