Skip to content

Commit

Permalink
replaced refs by atoms to prevent transactional locks
Browse files Browse the repository at this point in the history
  • Loading branch information
jestan committed Oct 15, 2011
1 parent e6cd0af commit 308c53b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(defproject closchema "0.0.2"
(defproject closchema "0.0.3-SNAPSHOT"
:description "Implements the JSON Schema specification."
:dependencies [[org.clojure/clojure "1.3.0"]]
:dev-dependencies [[swank-clojure "1.3.2"]]
:repositories {"releases" "http://192.168.0.7:8080/archiva/repository/internal/"
"snapshots" "http://192.168.0.7:8080/archiva/repository/snapshots/"})
12 changes: 6 additions & 6 deletions src/closchema/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
`(let [body# #(do ~@body
(process-errors @(:errors *validation-context*)))]
(if-not *validation-context*
(binding [*validation-context* {:errors (ref '())
:path (ref [])}]
(binding [*validation-context* {:errors (atom '())
:path (atom [])}]
(body#))
(body#))))

Expand All @@ -36,9 +36,9 @@
`(binding [*parent* ~parent]
(if-let [{path# :path} *validation-context*]
(do
(dosync alter path# conj ~rel-path)
(swap! path# conj ~rel-path)
~@body
(dosync alter path# pop))
(swap! path# pop))
(do ~@body))))


Expand All @@ -50,8 +50,8 @@
data (second args)]
`(let [error# {:ref ~path :key ~key :data ~data}]
(if-let [{errors# :errors path# :path} *validation-context*]
(dosync (alter errors# conj
(merge {:path (conj @path# ~path)} error#))))
(swap! errors# conj
(merge {:path (conj @path# ~path)} error#)))
(process-errors (list error#)))))


Expand Down

0 comments on commit 308c53b

Please sign in to comment.