nx_channel.nx
buildroot/runtime/nx_channel.nx
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
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
structs
| 36 | struct Chan |
consts
| none |
functions
| 46 | func chan_new(cap_hint: i64) -> *Chan calls 1: sys_mmap |
| 60 | func chan_is_empty(c: *Chan) -> i64 called by 1: chan_try_recv |
| 68 | func chan_is_full(c: *Chan) -> i64 called by 1: chan_try_send |
| 75 | func chan_try_send(c: *Chan, v: i64) -> i64 |
| 87 | func chan_try_recv(c: *Chan, out: *i64) -> i64 |
| 99 | func chan_send(c: *Chan, v: i64) -> i64 calls 1: chan_try_send |
| 109 | func chan_recv(c: *Chan) -> i64 |
| 122 | func chan_len(c: *Chan) -> i64 |