Skip to content

Commit a27bad1

Browse files
committed
Make kaocha.jit/jit thread-safe
1 parent 15e553d commit a27bad1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## Fixed
66

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

910
## Changed
1011

src/kaocha/jit.clj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
"Just in time loading of dependencies."
55
[sym]
66
`(do
7-
(require '~(symbol (namespace sym)))
7+
(locking ~(if (and (<= 1 (:major *clojure-version*))
8+
(<= 10 (:minor *clojure-version*)))
9+
'clojure.lang.RT/REQUIRE_LOCK
10+
(do (binding [*err* *out*]
11+
(println "WARNING: kaocha.jit is not thread-safe before Clojure 1.10"))
12+
::lock))
13+
(require '~(symbol (namespace sym))))
814
(find-var '~sym)))

0 commit comments

Comments
 (0)