Skip to content

Instantly share code, notes, and snippets.

@kwrooijen
Created June 24, 2020 13:05
Show Gist options
  • Save kwrooijen/c209c4d2317ce9ab4f7c39863f94099c to your computer and use it in GitHub Desktop.
Save kwrooijen/c209c4d2317ce9ab4f7c39863f94099c to your computer and use it in GitHub Desktop.
(deftype YggdrasilAtom [name state]
clojure.lang.IAtom
(reset [this f] (reset! (.-state this) f))
(swap [this a] (swap! (.-state this) a))
(swap [this a b] (swap! (.-state this) a b))
(swap [this a b c] (swap! (.-state this) a b c))
(swap [this a b c d] (swap! (.-state this) a b c d))
(compareAndSet [this a b] (compare-and-set! (.-state this) a b))
(toString [this] (str (.-name this)))
clojure.lang.IDeref
(deref [this] (deref (.-state this))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment