On 17 February 2010 06:18, Alex Ott <[email protected]> wrote: > send-off to dispatch tasks, that stores some data into central agent. > Tasks could be long running. > Yes, all send-off are sent to one agent, that accumulate information about > different documents
As Chouser pointed out, agents execute one thread at a time such that their data access is synchronized. This is the coordination model they expose. You want multiple threads so you need a different coordination model. I would suggest using a ref as the central data store that can be accessed by multiple worker threads. A convenient way of spawning CPU limited worker threads is to use (submit-future) to be found at the end of this thread: http://groups.google.com/group/clojure/browse_thread/thread/51cea7e25fdfe653 or at github http://github.com/timothypratley/strive/blob/master/clj/timothypratley/extensions.clj However there are of course many different approaches to consider: * use pcalls if appropriate * use multiple agents * use futures or threads * do work on thread but coordinate with ref/agent/atom Regards, Tim. -- 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
