code wiki / (root) / nx_lamport_clock.nx

nx_lamport_clock.nx

buildroot/runtime/nx_lamport_clock.nx

1160 B23 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_lamport_clock.nx -- Lamport logical clock (Leslie Lamport 1978): causal ordering across actors, the id source for the sequence CRDT. Each actor holds (clock, actor_id); tick() bumps + returns a monotonic clock for a new op; observe(remote) advances local to max(local,remote) so a happens-before edge always yields a strictly greater id. Combined with the actor_id tie-break this gives a DETERMINISTIC TOTAL ORDER every replica computes identically = the backbone of CRDT convergence. 100% integer. V-COLLAB rung. license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_lamport_clock.nx nx_crdt_sync.nx nx_crdt_sync_gate.nx

imports: nx_syscalls.nx

imported by: nx_crdt_sync.nxnx_crdt_sync_gate.nx

structs

none

consts

none

functions

9func lc_new(actor: i64) -> *i64
called by 1: main calls 1: sys_mmap
15func lc_actor(c: *i64) -> i64 { return c[1] }
called by 1: sync_insert
16func lc_value(c: *i64) -> i64 { return c[0] }
18func lc_tick(c: *i64) -> i64 { c[0] = c[0] + 1; return c[0] }
called by 1: sync_insert
20func lc_observe(c: *i64, remote: i64) -> i64
called by 1: sync_apply_log