Chez concurrency pt.3: async agents (per-agent serialized dispatch)
Replace the Janet synchronous agent shim (agent = atom, send applies inline) with JVM-style async agents: send/send-off enqueue an action and a single worker thread per agent applies them in order; deref reads the current (maybe not-yet-updated) state without blocking; await blocks until the queue drains. A validator rejection or a thrown action puts the agent in an error state (agent-error) and halts the queue; restart-agent clears it. send and send-off share one serialized worker (a superset of the JVM's fixed/cached pool split). Native versions re-asserted in post-prelude over the overlay; await/restart-agent are new. Corpus: the two "send/send-off applies" cases do (send a f) (deref a) with no await, so they now read state before the action runs — diverging like the JVM (the suite was literally "synchronous shim"). Allowlisted on both gates; floors -2 (zero-Janet 2569->2567, prelude 2559->2557). cli-test covers async agents via await (ordered 100-send dispatch, error capture) — 49/49. Janet gate + JVM cert green; 0 new divergences on either corpus. jolt-byjr
This commit is contained in:
parent
48ed72974f
commit
c719e54543
5 changed files with 120 additions and 7 deletions
|
|
@ -48,6 +48,16 @@
|
|||
(def-var! "clojure.core" "future?" jolt-future?)
|
||||
(def-var! "clojure.core" "promise" jolt-promise-new)
|
||||
(def-var! "clojure.core" "deliver" jolt-deliver)
|
||||
;; agents: the overlay (50-io) is a synchronous shim (agent = atom, send applies
|
||||
;; immediately). Re-assert the native async agents (per-agent serialized worker),
|
||||
;; matching the JVM. await/restart-agent are new (the overlay has neither).
|
||||
(def-var! "clojure.core" "agent" jolt-agent-new)
|
||||
(def-var! "clojure.core" "agent?" jolt-agent?)
|
||||
(def-var! "clojure.core" "send" jolt-agent-send)
|
||||
(def-var! "clojure.core" "send-off" jolt-agent-send)
|
||||
(def-var! "clojure.core" "await" jolt-agent-await)
|
||||
(def-var! "clojure.core" "agent-error" jolt-agent-error)
|
||||
(def-var! "clojure.core" "restart-agent" jolt-agent-restart)
|
||||
(def-var! "clojure.core" "deref" jolt-deref)
|
||||
(let ((overlay-realized? (var-deref "clojure.core" "realized?")))
|
||||
(def-var! "clojure.core" "realized?"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue