Expand description
Built-in demo chunks assembled with crate::Program.
Use these as runnable specs of the messaging contract (and as regression tests). Prefer copying a sample over inventing hop register layouts from scratch.
| Sample | Shows |
|---|---|
add_forty_two | Scalar VM path (no natives) |
ping_pong | Cap spawn + Atomic Hop round-trip |
atomic_request_reply | Tagged REQ/REP + print |
selective_receive | ReceiveMatch FIFO skip |
ask_reply | Ask RPC hop |
ask_timeout_expires | AskTimeout writes Unit when the server stays silent |
ask_target_exits | Ask dest is TAG_SYS_EXIT when the server dies first |
server_loop | BEAM-style receive → handle → reply loop |
forged_sender_send / forged_sender_ask | S1: forged make_msg sender dies |
boom | Immediate trap (supervisor demos) |
monitor_down | Monitor → crate::TAG_SYS_DOWN on child exit |
waiting_send | WAITING_SEND: second hop parks until the first is received |
Hop samples require crate::std_native_table.
Constants§
- TAG_
JUNK - Decoy hop for
selective_receive— must be skipped byReceiveMatch. - TAG_
PING - TAG_
PONG - TAG_REP
- TAG_REQ
- Protocol tags for Atomic Hop samples.
Functions§
- add_
forty_ two 41 + 1; return— the 60-second sanity chunk.- ask_
reply - Atomic request/reply via
Ask(RPC hop). - ask_
target_ exits - Server takes the request and exits; client
Askmust not hang. - ask_
timeout_ expires AskTimeoutagainst a server that never replies →Unit.- atomic_
request_ reply - Atomic request-reply with
crate::Value::Message(one envelope per hop). - boom
- Immediate
Trap— used to showcrate::Supervisorrestart. - forged_
sender_ ask - Same security property as
forged_sender_send, viaAsk. - forged_
sender_ send - Security regression: forged
make_msgsender must not surviveSend. - monitor_
down - Child sleeps then exits; parent monitors and returns the
DOWNreason (0= normal). - ping_
pong - Two flows, one Atomic Hop round-trip:
mainsends aMessagetopong,pongreplies with payload+1 viamsg_reply_cap,mainreturns that payload (2). - selective_
receive - Selective Atomic Hop: server waits for
TAG_REQwhile aTAG_JUNKhop sits ahead in the mailbox (FIFO skip, not drop). - server_
loop - BEAM-style server loop:
receive_match→ handle →send_reply→ repeat. - waiting_
send - Client arity 1 (
r0= server Cap) sends two hops; server drains both. With mailbox capacity 1 the second send parks (WAITING_SEND).