Real nREPL interrupt + thread-local *ns* (jolt-amzy, jolt-6rld)

Two nREPL divergences the library shakeout surfaced — both have a real host
mechanism on Chez.

Interrupt (jolt-amzy): Chez's engine timer (set-timer + thread-local
timer-interrupt-handler) is polled at procedure-call / loop back-edges, so a
running computation — even a tight loop — can be aborted from another thread.
concurrency.ss adds jolt.host/{make-interrupt, interrupt!, run-interruptible}: an
interrupt token is a shared box; run-interruptible arms a periodic timer whose
handler escapes (call/cc) when the token is set, throwing {:jolt/interrupted true}.
The eval thread is reused, not abandoned. (A thread blocked in a __collect_safe
foreign call only sees it on return — like the JVM not killing native code.)

Thread-local *ns* (jolt-6rld): chez-current-ns is now a Chez thread-parameter, so
each session worker / future has its own current ns (vars stay global, only the
pointer is per-thread). *ns* reads derive from it (dyn-binding.ss), and a bound
*ns* drives chez-current-ns — so (binding [*ns* the-ns] (load-string code))
resolves against the-ns, and concurrent in-ns across threads don't clobber each
other. Single-threaded behaviour is unchanged. All runtime .ss — no re-mint.
This commit is contained in:
Yogthos 2026-06-22 18:57:16 -04:00
parent f30a517cf7
commit c18f8087f0
6 changed files with 79 additions and 8 deletions

View file

@ -90,8 +90,8 @@
".clj (or .cljc) on the source roots") name))
(let ((saved (chez-current-ns)))
(load-jolt-file file)
(set-chez-ns! saved)
(def-var! "clojure.core" "*ns*" (intern-ns! saved)))))))
;; restore the current ns (thread-local); *ns* reads derive from it.
(set-chez-ns! saved))))))
;; load-file: load an explicit path (a `run FILE`), in the current ns.
(define (jolt-load-file path)