ClojureDocs

Nav

Namespaces

await-for

clojure.core

Available since 1.0 (source)
  • (await-for timeout-ms & agents)
Blocks the current thread until all actions dispatched thus
far (from this thread or agent) to the agents have occurred, or the
timeout (in milliseconds) has elapsed. Returns logical false if
returning due to timeout, logical true otherwise.
1 Example
;; construct simple agent
(def agnt (agent 5))

;; increment agent
(send agnt inc) 

;; system does not wait for the value change
(println @agnt) 
;; => 5 

;; increment agent
(send agnt inc)

;; wait for maximum 1000 ms
(await-for 1000 agnt) 

;; print out the value of the agent 
(println @agnt) 
;; => 7
See Also

Blocks the current thread (indefinitely!) until all actions dispatched thus far, from this thread ...

Added by ninjudd
0 Notes
No notes for await-for