feat(stdlib): Jobs, Promises & opt-in Sync concurrency (#14)
A layered concurrency library, safe by default. The recommended tier is Job.* / Promise.*: a Job is a future — Job.run(kind, arg) starts a cooperative background compute that advances each Job.pump(budget) and finishes after enough frames (heavy work spreads out instead of hitching), or Job.defer + Job.fulfill/fail/cancel drives one by hand. Poll with done/ok/failed/cancelled, read result/error, count outstanding work with Job.pending. Promise.all/race combine handle lists into a group job resolved on the main thread; Promise.count_done/all_done power a loading bar. The advanced, opt-in Sync.* tier (mutex/atomic/channel + cpu_count) is the "here be dragons" surface for engine-level message passing. The whole thing is a deterministic cooperative scheduler: results are collected on the main thread and a Job never touches the ECS world, so lockstep and replays stay bit-exact — same jobs + same budget reproduce byte-for-byte on every target, and a preemptive OS-thread backend can slot behind this same API later. Ludic has no closures, so a Job carries a compute kind + int arg (or a hand-driven defer) rather than fn()->…, and Promise progress is polled rather than chained through then. Written in Ludic and spliced on demand (like Regex/Dict/Numeric): a program that never mentions Job.*/Promise.*/Sync.* compiles byte-identically and the C-free bootstrap fixpoint is untouched. New: runtime/native/jobs.ludic, emit_ns_call dispatch, parse-time splice, examples/library/jobs.ludic (31 self-asserting checks), 33 docs pages + inventory, changeset. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
872f458cb2
commit
50ecb8472f
44 changed files with 25637 additions and 22806 deletions
7
docs/language/sync/_section.md
Normal file
7
docs/language/sync/_section.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
id: sync
|
||||
title: Sync
|
||||
order: 39
|
||||
---
|
||||
|
||||
The advanced, opt-in tier — <strong>here be dragons</strong>. Raw building blocks for engine-level systems that pass data around: a <code>mutex</code> (cooperative lock), an <code>atomic</code> counter (<code>get</code> / <code>set</code> / <code>add</code> / <code>cas</code>) and a bounded <code>channel</code> (<code>send</code> / <code>recv</code> / <code>can_recv</code> / <code>len</code>). On today's single-threaded deterministic runtime these are cooperative — correct, ordered, replayable and impossible to deadlock — and exist so message-passing code reads the same now as it will when a preemptive OS-thread backend lands behind this same API. Beginners never need this; reach for <code>Job.*</code> / <code>Promise.*</code> instead. Spliced in only when a program mentions <code>Sync.*</code>.
|
||||
Loading…
Add table
Add a link
Reference in a new issue