summaryrefslogtreecommitdiff
path: root/src/boot.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot.clj')
-rw-r--r--src/boot.clj21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/boot.clj b/src/boot.clj
index b1dbe2ab..53fd5842 100644
--- a/src/boot.clj
+++ b/src/boot.clj
@@ -287,3 +287,24 @@
(. Var (pushThreadBindings (hash-map ~@(var-ize bindings))))
~@body)
(. Var (popThreadBindings)))))
+
+;;Refs
+(defn ref [x]
+ (new Ref x))
+
+(defn deref [#^Ref ref]
+ (. ref (get)))
+
+(defn deref! [#^Ref ref]
+ (. ref (currentVal)))
+
+(defn commute [#^Ref ref fun]
+ (. ref (commute fun)))
+
+(defn set [#^Ref ref val]
+ (. ref (set val)))
+
+(defmacro sync [& body]
+ `(. clojure.lang.LockingTransaction
+ (runInTransaction (fn [] ~@body))))
+