Skip to content

Commit

Permalink
Make kaocha.jit/jit thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Dec 22, 2024
1 parent 15e553d commit a27bad1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## Fixed

- Fix beholder watch functionality that would cause a NullPointerException earlier.
- Make `kaocha.jit/jit` thread-safe in Clojure 1.10+. For lower versions, best effort with printed warning.

## Changed

Expand Down
8 changes: 7 additions & 1 deletion src/kaocha/jit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
"Just in time loading of dependencies."
[sym]
`(do
(require '~(symbol (namespace sym)))
(locking ~(if (and (<= 1 (:major *clojure-version*))
(<= 10 (:minor *clojure-version*)))
'clojure.lang.RT/REQUIRE_LOCK
(do (binding [*err* *out*]
(println "WARNING: kaocha.jit is not thread-safe before Clojure 1.10"))
::lock))
(require '~(symbol (namespace sym))))
(find-var '~sym)))

0 comments on commit a27bad1

Please sign in to comment.