This is all good advice. Also notice that these examples don't really match real life use cases of core.async. Here you only have two threads, where the execution time is dominated by message passing. In most situations you'll have dozens (or hundreds) of gos, with actual work being done in each logical thread. In these cases, I highly doubt the performance of core.async will be the bottleneck.
But give it a try on a real project and let tell us how it goes. Timothy On Fri, Nov 29, 2013 at 10:04 AM, Thomas Heller <i...@zilence.net> wrote: > Ah forgot that the core.async folks mentioned that if you want performance > its best to use real threads. > > (time > (let [c (chan 100)] > (thread > (dotimes [i 100000] > (>!! c i)) > (close! c)) > (prn (<!! (thread (loop [i nil] > (if-let [x (<!! c)] > (recur x) > i))))))) > > > finishes in about 100ms which seems reasonable, just can't have too many > of those threads open. > > > On Fri, Nov 29, 2013 at 5:40 PM, Sean Corfield <seancorfi...@gmail.com>wrote: > >> On Fri, Nov 29, 2013 at 1:09 AM, Thomas Heller <th.hel...@gmail.com> >> wrote: >> > I'm actually surprised you get to "stop" at all. You send a couple items >> > onto the channel but don't close it, therefore the 2nd go block will >> > potentially block forever waiting for more. >> >> Indeed. When I tried Andreas' code in the REPL, it didn't terminate. >> >> > I'm far from an expert in core.async but I think the solution would be >> to >> > close! the channel and as a suggestion: (go) blocks themselves return >> > channels that "block" until they are completed. You could write this as: >> >> Your code completes in around 330ms for me. >> -- >> Sean A Corfield -- (904) 302-SEAN >> An Architect's View -- http://corfield.org/ >> World Singles, LLC. -- http://worldsingles.com/ >> >> "Perfection is the enemy of the good." >> -- Gustave Flaubert, French realist novelist (1821-1880) >> >> -- >> -- >> 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 >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "Clojure" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/clojure/m6bqGd8vQZQ/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> clojure+unsubscr...@googlegroups.com. >> >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > -- > 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 > --- > 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 clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.