core.sync is more about coordination and communication than about doing things in parallel, thats just a pleasant side effect.
In your case you don't need anything core.async provides. You could either use reducers or java.util.concurrent.ExecutorService. (let [exec (Executors/newFixedThreadPool 4) process (fn [it] (.submit exec #(long-running-widget-processor it))) get (fn [future] (.get future))] (->> widgets (mapv process) (mapv get))) This skips the partitioning of the inputs and lets the Threadpool deal with spreading the work. This probably is optimal to ensure that all 4 threads are busy until all work is done. (Note: I did not run this code) Reducers would be good if the number of items processed is large enough and you are doing pure number crunching with no I/O. Otherwise the fork/join probably costs too much. HTH, /thomas On Friday, September 5, 2014 7:46:02 AM UTC+2, Beau Fabry wrote: > > Is the kinda ugly constant (doall usage a sign that I'm doing something > silly? > > (let [num-workers 4 > widgets-per-worker (inc (int (/ (count widgets) num-workers))) > bucketed-widgets (partition-all widgets-per-worker widgets) > workers (doall (map (fn [widgets] > (thread > (doseq [widget widgets] > (long-running-widget-processor widget)) > true)) > bucketed-widgets))] > (doall (map <!! workers))) > > https://gist.github.com/bfabry/ad830b1888e4fc550f88 > > All comments appreciated :-) > > Cheers, > Beau > -- 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/d/optout.