store/[org.clojure/clojure "1.8.0"] clj::clojure.core/await

Official Documentation

Add notes
Arities
==================================================
   [& agents]

Docstring
==================================================
  Blocks the current thread (indefinitely!) until all actions
  dispatched thus far, from this thread or agent, to the agent(s) have
  occurred.  Will block on failed agents.  Will never return if
  a failed agent is restarted with :clear-actions true.

Source

(defn await
  "Blocks the current thread (indefinitely!) until all actions
  dispatched thus far, from this thread or agent, to the agent(s) have
  occurred.  Will block on failed agents.  Will never return if
  a failed agent is restarted with :clear-actions true."
  {:added "1.0"
   :static true}
  [& agents]
  (io! "await in transaction"
    (when *agent*
      (throw (new Exception "Can't await in agent action")))
    (let [latch (new java.util.concurrent.CountDownLatch (count agents))
          count-down (fn [agent] (. latch (countDown)) agent)]
      (doseq [agent agents]
        (send agent count-down))
      (. latch (await)))))

Example 1

Edit
(def *agnt* (agent {}))
;; => #'user/*agnt*

(send-off *agnt* (fn [state] 
                   (Thread/sleep 10000)
                   (assoc state :done true)))
;; => #<Agent@5db18235: {}>

(await *agnt*) ; blocks till the agent action is finished
;; => nil

Uses on crossclj