Alpha - subject to change.
Delivers the supplied value to the promise, releasing any pending
derefs. A subsequent call to deliver on a promise will throw an exception.
user=> (def x (promise)) #'user/x ;; Trying to deref at this point will make your repl wait forever user=> (deliver x 100) #<core$promise$reify__5534@4369a50b: 100> ;; the promise has been delivered, deref x will return immediately user=> @x 100
;; Create a promise user> (def p (promise)) #'user/p ; p is our promise ;; Check if was delivered/realized user> (realized? p) false ; No yet ;; Delivering the promise user> (deliver p 42) #<core$promise$reify__5727@47122d: 42> ;; Check again if it was delivered user> (realized? p) true ; Yes! ;; Deref to see what has been delivered user> @p 42 ;; Note that @ is shorthand for deref user> (deref p) 42
(defn deliver
"Alpha - subject to change.
Delivers the supplied value to the promise, releasing any pending
derefs. A subsequent call to deliver on a promise will throw an exception."
{:added "1.1"}
[promise val] (promise val))
Comments top
No comments for deliver. Log in to add a comment.