nx_remote_worker.nx
buildroot/runtime/nx_remote_worker.nx
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
imports: nx_syscalls.nxnx_atom.nxnx_thread.nxnx_socket.nxnx_net_chan.nx
imported by: nx_remote_worker_test.nx
structs
| 37 | struct NxRemoteWorker |
consts
| 32 | const NX_MAGIC_65536: i64 = 65536 |
| 33 | const NX_MAGIC_100000000: i64 = 100000000 |
| 35 | const NX_REMOTE_SENTINEL: i64 = -1 |
| 44 | const NX_REMOTE_WORKER_BYTES: i64 = 32 |
functions
| 49 | func _nx_remote_worker_main(arg: *u8) -> i64 |
| 96 | func nx_remote_worker_start(handler: func(i64, i64) -> i64, port: i64) -> *NxRemoteWorker |
| 118 | func nx_remote_orchestrator_connect(port: i64) -> *NxNetChan called by 1: main calls 6: nx_sock_socketsys_mmapnx_sock_sin_initnx_sock_connectsys_closenx_net_chan_from_fd |
| 128 | func nx_remote_dispatch(nc: *NxNetChan, task_id: i64, arg: i64, out: *i64) -> i64 |
| 135 | func nx_remote_shutdown(nc: *NxNetChan) -> i64 |
| 140 | func nx_remote_worker_alive(w: *NxRemoteWorker) -> i64 calls 1: nx_atom_load_i64 |