pub enum VmResult {
Complete(Value),
Yield,
Sleep(Duration),
Spawn {
function: u32,
args: Vec<Value>,
dest_reg: u8,
},
SelfPid {
dest_reg: u8,
},
Send {
target_cap: u64,
message: Value,
},
Receive {
dest_reg: u8,
timeout: Option<Duration>,
match_tag: Option<u16>,
},
Ask {
dest_reg: u8,
target_cap: u64,
request: Value,
},
Trap(Fault),
}Expand description
What happened at the end of a crate::Vm::run slice.
This is the entire interface between byteflow-vm and the scheduler: the
VM never touches threads, mailboxes or timers directly. It runs bytecode
until it either finishes, needs an effect only the scheduler can perform,
or exhausts its instruction budget — then hands one of these back and
stops. That separation is what lets byteflow-scheduler move a suspended
Vm between worker threads freely: it’s just a value sitting in a
Flow.
Variants§
Complete(Value)
The outermost frame returned/exited. The Flow should terminate
with this value delivered to FlowHandle::join.
Yield
Cooperative yield or instruction-budget exhaustion. Re-enqueue as
Ready on any worker; resuming picks up at the saved pc with no
register writeback needed.
Sleep(Duration)
Sleep opcode. Register the Flow on the timer wheel; resume with
a plain run() call (no writeback) once it elapses.
Spawn
Spawn — create a child flow; parent receives a Cap (SEND|ASK).
SelfPid
SelfPid — write a self Cap (SEND|ASK) into dest_reg.
Send
Send — Atomic Hop to a capability target (requires SEND).
Receive
Receive / ReceiveTimeout / ReceiveMatch / ReceiveMatchImm.
Ask
Ask — RPC hop to a capability target (requires ASK).
Trap(Fault)
A fault occurred; the Flow fails. See Fault.