pmap already uses future/deref in its implementation.  When it does so, it
limits the *maximum* parallelism possible to be at most (number-of-cpus + 2)
threads running at a time, and depending upon the time taken by each of the
objects you are mapping over, it can be less then that.

I don't know if it would work for your purposes, but Amit Rathore created a
small Clojure library called Medusa that is basically a wrapper around Java
executors:

https://github.com/amitrathore/medusa

Andy


On Wed, Sep 21, 2011 at 4:06 PM, ronen <nark...@gmail.com> wrote:

> I was looking for a pure Clojure solution to run multiple non-
> dependant tasks on multiple threads, iv considered using Agent,
> Promises or Futures, yet the simplest cleanest succinct solution iv
> found is:
>
> (defn email-approved [approved]
>  (doall (pmap deref (for [req approved] (future (email-request
> req))))))
>
> The only thing that I don't like about it is the use of pmap, main
> since Im using the parallel mapping action just for side effects
> (triggering the consumptions of futures by derefing them).
>
> Iv seen solution that involve Java service executor and the Work
> project (https://github.com/getwoven/work), yet id rather achieve this
> in pure Clojure.
>
> Thanks
> Ronen
>
> --
> 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 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