code wiki / (root) / nx_remote_worker.nx

nx_remote_worker.nx

buildroot/runtime/nx_remote_worker.nx

5405 B144 linesdepth 5pulls 8 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_remote_worker.nx -- distributed-MIMD pattern: orchestrator dispatches typed tasks to a worker over NetChan; worker computes and returns results. Single-process demo (worker is a spawned thread that listens on TCP); same shape works across hosts when the worker side runs as a remote process. Composes against: [[nx_net_chan_tcp_i64]] -- transport [[thread_clone_native_trampoline]] -- worker thread [[fn_ptr_indirect_call]] -- worker dispatches via typed fn-ptr Worker protocol (per task): 1. orchestrator sends task_id (i64) 2. orchestrator sends arg (i64) 3. worker runs registered_fn(task_id, arg) -> result (i64) 4. worker sends result (i64) 5. orchestrator recvs result Sentinel task_id (-1) signals worker to exit cleanly.

dependencies 5 imports · 1 importers

nx_syscalls.nx nx_atom.nx nx_thread.nx nx_socket.nx nx_net_chan.nx nx_remote_worker.nx nx_remote_worker_test.nx

imports: nx_syscalls.nxnx_atom.nxnx_thread.nxnx_socket.nxnx_net_chan.nx

imported by: nx_remote_worker_test.nx

structs

37struct NxRemoteWorker

consts

32const NX_MAGIC_65536: i64 = 65536
33const NX_MAGIC_100000000: i64 = 100000000
35const NX_REMOTE_SENTINEL: i64 = -1
44const NX_REMOTE_WORKER_BYTES: i64 = 32

functions

49func _nx_remote_worker_main(arg: *u8) -> i64
96func nx_remote_worker_start(handler: func(i64, i64) -> i64, port: i64) -> *NxRemoteWorker
118func nx_remote_orchestrator_connect(port: i64) -> *NxNetChan
128func nx_remote_dispatch(nc: *NxNetChan, task_id: i64, arg: i64, out: *i64) -> i64
135func nx_remote_shutdown(nc: *NxNetChan) -> i64
140func nx_remote_worker_alive(w: *NxRemoteWorker) -> i64