code wiki / (root) / channel.nx

channel.nx

buildroot/runtime/channel.nx

4073 B118 linesdepth 3pulls 3 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

syscalls.nx channel.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

structs

30struct Chan {

consts

none

functions

40func chan_new(cap_hint: i64) -> *Chan {
54func chan_is_empty(c: *Chan) -> i64 {
called by 1: chan_try_recv
62func chan_is_full(c: *Chan) -> i64 {
called by 1: chan_try_send
69func chan_try_send(c: *Chan, v: i64) -> i64 {
called by 1: chan_send calls 1: chan_is_full
81func chan_try_recv(c: *Chan, out: *i64) -> i64 {
called by 1: chan_recv calls 1: chan_is_empty
93func chan_send(c: *Chan, v: i64) -> i64 {
calls 1: chan_try_send
103func chan_recv(c: *Chan) -> i64 {
calls 1: chan_try_recv
116func chan_len(c: *Chan) -> i64 {