code wiki / (root) / io.nx

io.nx

buildroot/runtime/io.nx

4942 B139 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

io.nx -- epoll-based non-blocking event loop (Phase G3). Research / reference: Linux epoll (2.5.45, 2002) — the scalable alternative to select and poll. Watches thousands of fds in O(1) per ready event. Nginx / redis / node.js all run on this model. Sovereignty: direct epoll_create1 / epoll_ctl / epoll_wait syscalls. No libev, no libuv, no glibc epoll wrapper. The same API works on NishiOS once its equivalent interrupt-dispatched ready-queue ships. Pattern for single-threaded server on this loop: let ep: i64 = io_epoll_new() io_epoll_add(ep, listen_fd, IO_READ) let evs: *IoEvent = io_events_alloc(64) while serving { let n: i64 = io_wait(ep, evs, 64, -1) var i: i64 = 0 while i < n { let e: *IoEvent = io_event_at(evs, i) handle(e.fd, e.events) i = i + 1 } } Syscalls (Linux RV64): 20 epoll_create1 21 epoll_ctl 22 epoll_pwait Event masks (subset we support): EPOLLIN = 0x001 — readable EPOLLOUT = 0x004 — writable EPOLLHUP = 0x010 — peer hangup EPOLLET = 0x80000000 — edge-triggered (uint32 bit 31)

dependencies 1 imports · 0 importers

syscalls.nx io.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

structs

61struct IoEvent {

consts

41const SYS_EPOLL_CREATE1: i64 = 20
42const SYS_EPOLL_CTL: i64 = 21
43const SYS_EPOLL_PWAIT: i64 = 22
45const EPOLL_CTL_ADD: i64 = 1
46const EPOLL_CTL_DEL: i64 = 2
47const EPOLL_CTL_MOD: i64 = 3
49const IO_READ: i64 = 0x001 // EPOLLIN
50const IO_WRITE: i64 = 0x004 // EPOLLOUT
51const IO_HUP: i64 = 0x010 // EPOLLHUP
66const IO_EVENT_BYTES: i64 = 16
128const SYS_FCNTL: i64 = 25
129const F_GETFL: i64 = 3
130const F_SETFL: i64 = 4
131const O_NONBLOCK: i64 = 0x800

functions

70func io_epoll_new() -> i64 {
77func io_epoll_add(ep: i64, fd: i64, events: i64) -> i64 {
87func io_epoll_mod(ep: i64, fd: i64, events: i64) -> i64 {
98func io_epoll_del(ep: i64, fd: i64) -> i64 {
104func io_events_alloc(n: i64) -> *IoEvent {
109func io_event_at(evs: *IoEvent, i: i64) -> *IoEvent {
117func io_wait(ep: i64, evs: *IoEvent, max_events: i64,
135func io_set_nonblock(fd: i64) -> i64 {