2011/1/24 Michael Gardner <gardne...@gmail.com>:
> Suppose I have a sequence of tasks I'd like to parallelize using pmap. The 
> amount of CPU time these tasks require varies greatly; in particular, many of 
> them will require virtually no work. Can I rely on pmap to divide the work 
> efficiently even if there is some pattern to the distribution of easy tasks 
> (e.g. clumped at the beginning, or every nth)? Assume it's not possible to 
> identify the easy tasks beforehand.

If you simply want all tasks to be performed as quickly as possible,
one alternative could be to use an ExecutorService (perhaps one
created with newFixedThreadPool) with its invokeAll method. invokeAll
takes a collection of callables (in clojure terms: you can pass it a
seq of zero-arg functions) and returns a collection of futures. An
ExecutorService could perhaps give you fine-grained control.

I recently wrote a blog post on this; you might find it interesting:
http://blog.raek.se/2011/01/24/executors-in-clojure/

// raek

-- 
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