nx_stream_multiplexer.nx
buildroot/runtime/nx_stream_multiplexer.nx
about
nx_stream_multiplexer.nx -- interleaved concurrent modality streams.
Per CARDINAL [[feedback-parallel-companion-multimodal-dnd-real-time]]:
LLM streaming + image gen + video + audio TTS + game actions must run
CONCURRENT on one RTX 5080 with sub-50ms preemption. The multiplexer
is the substrate that orders + interleaves output tokens from multiple
generators into one ordered output stream the operator perceives.
V1 ships sealed stream-class enum (one per modality), per-stream
priority (LLM speech > game actions > image > video > audio fill),
chunk arrival timestamps, fairness budget (no starvation), and
next-chunk arbitration that respects priority + freshness + budget.
dependencies 2 imports · 11 importers
diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_bench_companion.nxnx_companion_compose_test.nxnx_dual_companion_compose_test.nxnx_dual_real_llm_compose_test.nxnx_dual_real_llm_emit_test.nxnx_quad_companion_compose_test.nxnx_quad_real_emit_test.nxnx_session.nxnx_session_test.nxnx_stream_multiplexer_test.nxnx_triple_companion_compose_test.nx
structs
| 39 | struct NxStreamChunk |
| 50 | struct NxStreamMultiplexer |
consts
| 19 | const NX_SM_CLASS_LLM_TEXT: nx_int = 0 |
| 20 | const NX_SM_CLASS_GAME_ACTION: nx_int = 1 |
| 21 | const NX_SM_CLASS_AUDIO_TTS: nx_int = 2 |
| 22 | const NX_SM_CLASS_IMAGE_TILE: nx_int = 3 |
| 23 | const NX_SM_CLASS_VIDEO_FRAME: nx_int = 4 |
| 24 | const NX_SM_CLASS_TOOL_RESULT: nx_int = 5 |
| 25 | const NX_SM_CLASS_SYSTEM_EVENT: nx_int = 6 // highest priority, always wins |
| 26 | const NX_SM_CLASS_N: nx_int = 7 |
| 30 | const NX_SM_V_DELIVERED: nx_int = 0 |
| 31 | const NX_SM_V_EMPTY: nx_int = 1 // no chunks available |
| 32 | const NX_SM_V_STARVED: nx_int = 2 // backed off a stream that hit budget |
| 33 | const NX_SM_V_INVALID: nx_int = 3 |
| 34 | const NX_SM_V_NULL: nx_int = 4 |
| 35 | const NX_SM_V_N: nx_int = 5 |
| 48 | const NX_SM_C_BYTES: nx_int = 48 |
| 66 | const NX_SM_BYTES: nx_int = 80 |
functions
| 70 | func nx_sm_class_is_valid(c: nx_int) -> nx_int |
| 76 | func nx_sm_v_is_valid(v: nx_int) -> nx_int called by 1: main |
| 85 | func nx_sm_class_priority(c: nx_int) -> nx_int |
| 98 | func nx_sm_new(capacity: nx_int, |
| 131 | func _sm_chunk_at(m: *NxStreamMultiplexer, idx: nx_int) -> *NxStreamChunk |
| 138 | func nx_sm_push(m: *NxStreamMultiplexer, |
| 165 | func nx_sm_peek_next(m: *NxStreamMultiplexer, now_us: nx_size) -> *NxStreamChunk |
| 198 | func _sm_remove_at(m: *NxStreamMultiplexer, idx: nx_int) -> nx_int |
| 223 | func nx_sm_next(m: *NxStreamMultiplexer, |
| 274 | func nx_sm_epoch_tick(m: *NxStreamMultiplexer) -> nx_int |
| 288 | func nx_sm_pending_count(m: *NxStreamMultiplexer) -> nx_int |
| 293 | func nx_sm_served_count(m: *NxStreamMultiplexer, stream_class: nx_int) -> nx_int |