Provides a thread local place, using a dynamic var.
A thread local place can be given a value using with-thread-locals
. It is an
error to use with-thread-locals
if the thread local already has a value.
The current value of the thread local is found with thread-local
.
The current value of the thread local can be set with thread-local!
. It is an
error to set the value on a thread other than the one used to provide the
initial value using with-thread-locals
.
(def ^:dynamic *tl*)
(with-thread-locals [*t1* {}]
(assert (= (thread-local *tl*) {}))
(thread-local! *tl* {:a 1})
(assert (= (thread-local *tl*) {:a 1})))
Provides a thread local place, using a dynamic var. A thread local place can be given a value using `with-thread-locals`. It is an error to use `with-thread-locals` if the thread local already has a value. The current value of the thread local is found with `thread-local`. The current value of the thread local can be set with `thread-local!`. It is an error to set the value on a thread other than the one used to provide the initial value using `with-thread-locals`. (def ^:dynamic *tl*) (with-thread-locals [*t1* {}] (assert (= (thread-local *tl*) {})) (thread-local! *tl* {:a 1}) (assert (= (thread-local *tl*) {:a 1})))
(thread-local sym)
Get the value of the thread local
Get the value of the thread local
(thread-local! sym value)
Reset the value of a thread local
Reset the value of a thread local
(with-thread-locals bindings & body)
Assign an initial value to a thread local.
Assign an initial value to a thread local.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close