Is there a standard way to wait for a given set of go-blocks to finish?  I 
think this is the same as waiting for a given set of channels to close.

GoLang seems to have WaitGroup for this purpose:
http://stackoverflow.com/a/21819794/142317

Here's a CLJSfiddle of my current solution:
http://cljsfiddle.net/fiddle/shaunlebron.wait-all-close

(I'm intentionally ignoring the values written to the go-block channels 
because I only want to know when they're done.

(defn wait-all-close
  "Returns a channel that closes when all the given channels have closed."
  [chans]
  (async/filter< nil? (async/merge chans)))

(go
  (let [chans [(go (<! (timeout 2000)) (print "foo"))
               (go (<! (timeout 500)) (print "bar"))]]
    (<! (wait-all-close chans))
    (print "Go-routines done.")))

Could we get something like this in the core.async API?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to