diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-09-10 18:31:16 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-09-10 18:31:16 +0000 |
commit | d7409821765ae40fd2995ff11fe5bcd99ce0d900 (patch) | |
tree | 485ea626e0336fa4425e337b76bd10d01130bf66 /src | |
parent | 1b58410d0343074980c0a5c3e4da18960810aded (diff) |
modified load to detect and prevent loading a resource while another load of the same resource is pending in the same thread
patch from Stephen C. Gilardi
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/boot.clj | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/clj/clojure/boot.clj b/src/clj/clojure/boot.clj index 85dc6be5..d4c73f82 100644 --- a/src/clj/clojure/boot.clj +++ b/src/clj/clojure/boot.clj @@ -3007,6 +3007,11 @@ *loaded-libs* (ref (sorted-set))) (defonce + #^{:private true + :doc "the set of paths currently being loaded by this thread"} + *pending-paths* #{}) + +(defonce #^{:private true :doc "True while a verbose load is pending"} *loading-verbosely* false) @@ -3212,7 +3217,11 @@ (when *loading-verbosely* (printf "(clojure/load \"%s\")\n" path) (flush)) - (.loadResourceScript clojure.lang.RT (.substring path 1))))) + (throw-if (*pending-paths* path) + "cannot load '%s' again while it is loading" + path) + (binding [*pending-paths* (conj *pending-paths* path)] + (.loadResourceScript clojure.lang.RT (.substring path 1)))))) ;;;;;;;;;;;;; nested associative ops ;;;;;;;;;;; |