Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
thread-local values
(defmacro thread-local
"Create a thread local, initialised by body. The value can be obtained by
dereferncing the the thread-local with deref/@."
[& body]
`(proxy [java.lang.ThreadLocal clojure.lang.IDeref] []
(~'initialValue
[] ~@body)
(~'deref
[] (.get ~'this))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.