Hi there,

I'm playing with a little problem (calculating pi) that is "trivially
parallelizable" in that I can easily break the calculation up into a
bunch of chunks, send them off to workers and gather the results back
together. The one additional requirement I have is that I'd like the
process to be cancelable. I was wondering how others would go about
doing this, especially in pure Clojure, i.e. without the help of any
libraries. Here are some ideas I've had:

* Each piece of work is a future which sends its result to an agent
that accumulates the final result. This works, but to cancel the work,
I have to keep the futures around and call (future-cancel) on each.
This seems to cause a noticeable lag in the time it takes to cancel.
Also, there doesn't seem to be a good way to cancel the results that
are queued to the accumulator agent. Maybe I should just accumulate in
an atom.

* Create a pool of agents that block on a shared work queue. Then to
cancel, I can just clear the queue. This seems like an abuse of
agents, treating them as threads rather than a data structure with
asynchronous update semantics.

* Use the Work library (https://github.com/getwoven/work). Seems
straightforward enough, but I'm interested in learning about what I
can do with Clojure "out of the box".

* Use Lamina (https://github.com/ztellman/lamina). Same story as Work.

A side note: isn't it interesting that both Work and Lamina have
exactly the same number of github watchers (87) and forks (11). Weird.

Thoughts?

Thanks!

Dave

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

Reply via email to