code wiki / (root) / nx_channel.nx

nx_channel.nx

buildroot/runtime/nx_channel.nx

4209 B124 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

channel.nx -- typed message-passing primitive (Phase M1 seed). Research: Honda 1993 ("Types for Dyadic Interaction"), Pony actor-channel model, Go channels with session-type extensions. The long-term destination is full session types (Honda 1998) where the channel's type describes the entire protocol; this file ships the foundation on which session-type checking will stack in a future parse.nx pass. Today's capabilities: * Typed FIFO channel with bounded capacity * Non-blocking try_send / try_recv * Blocking send / recv (spin-on-empty/full; MCU-friendly) * Single-producer single-consumer (SPSC); MPSC / MPMC variants ship in a follow-up once we have atomic primitives Currently specialised to i64 message type; generalises to Chan<T> when full multi-parameter generics land in parse.nx. Scaling claim: same channel.nx source compiles on MCU (no kernel threads, cooperative yield via __wfi between poll attempts) and on supercomputer (the scheduler's context switch uses the same primitive). Nothing about the API changes.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_channel.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

structs

36struct Chan

consts

none

functions

46func chan_new(cap_hint: i64) -> *Chan
calls 1: sys_mmap
60func chan_is_empty(c: *Chan) -> i64
called by 1: chan_try_recv
68func chan_is_full(c: *Chan) -> i64
called by 1: chan_try_send
75func chan_try_send(c: *Chan, v: i64) -> i64
called by 1: chan_send calls 1: chan_is_full
87func chan_try_recv(c: *Chan, out: *i64) -> i64
called by 1: chan_recv calls 1: chan_is_empty
99func chan_send(c: *Chan, v: i64) -> i64
calls 1: chan_try_send
109func chan_recv(c: *Chan) -> i64
122func chan_len(c: *Chan) -> i64