From d7409821765ae40fd2995ff11fe5bcd99ce0d900 Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Wed, 10 Sep 2008 18:31:16 +0000 Subject: 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 --- src/clj/clojure/boot.clj | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') 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 @@ -3006,6 +3006,11 @@ :doc "A ref to a sorted set of symbols representing loaded libs"} *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"} @@ -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 ;;;;;;;;;;; -- cgit v1.2.3-18-g5258