(->RetryingDelay fun available? value)
Positional factory function for class clojure.core.memoize.RetryingDelay.
Source
(deftype RetryingDelay [fun ^:volatile-mutable available? ^:volatile-mutable value]
clojure.lang.IDeref
(deref [this]
;; first check (safe with volatile flag)
(if available?
value
(locking fun
;; second check (race condition with locking)
(if available?
value
(do
;; fun may throw - will retry on next deref
(let [v (fun)]
;; this ordering is important - MUST set value before setting available?
;; or you have a race with the first check above
(set! value v)
(set! available? true)
v)))))))