Current doc string:

  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.

What it doesn't note is that (as is typical, mind you, of blocking
methods in Java) you can kick the thread out of its funk with
interrupt:

; Make an agent
=> (def a (agent 1))
#'user/a
 ; Make agent busy and cause it to fail after five seconds
=> (send a #(do (Thread/sleep 5000) (/ % 0)))
#<Agent@53d34c: 1>
; Make a thread that will await the agent
=> (def t (Thread. #(try
                      (await a)
                      (catch InterruptedException _
                        (println "boo!")))))
#'user/t
; Start it
=> (.start t)
nil
; Interrupt it (wait a few seconds before issuing this)
=> (.interrupt t)
boo!
nil

So, await can be interrupted and will then throw InterruptedException,
which can be caught and handled. This provides a possible means of
recovery from the "will never return..." condition described in the
docs.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to