channel.nx
buildroot/runtime/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: syscalls.nx
imported by: nobody (leaf or entry point)
structs
| 30 | struct Chan { |
consts
| none |
functions
| 40 | func chan_new(cap_hint: i64) -> *Chan { |
| 54 | func chan_is_empty(c: *Chan) -> i64 {
called by 1: chan_try_recv |
| 62 | func chan_is_full(c: *Chan) -> i64 {
called by 1: chan_try_send |
| 69 | func chan_try_send(c: *Chan, v: i64) -> i64 { |
| 81 | func chan_try_recv(c: *Chan, out: *i64) -> i64 { |
| 93 | func chan_send(c: *Chan, v: i64) -> i64 {
calls 1: chan_try_send |
| 103 | func chan_recv(c: *Chan) -> i64 {
calls 1: chan_try_recv |
| 116 | func chan_len(c: *Chan) -> i64 { |