On Wed, 10 Jun 2009 12:44:00 -0600 Daniel Lyons <fus...@storytotell.org> wrote: > On Jun 10, 2009, at 12:03 PM, Toralf Wittner wrote: > > On Wed, 2009-06-10 at 10:22 -0600, Daniel Lyons wrote: > >> If the actions are executed serially, what is the benefit of having > >> multiple threads per agent? > > > > There is none. Did anybody say there are multiple threads per agent? > > There are two thread pools shared by all agents - a cached thread > > pool where actions enqueued via send-off go into and a fixed thread > > pool for > > actions enqueued via send. The actions of all agents are submitted > > to these two pools and all together run interleaved in different > > threads. However at a given point in time there is only one thread > > for a given Agent. And an agent's actions run one after another. > > > This makes more sense, actually. For some reason I thought each > agent got its own thread pool. > > However, I still feel like I am not understanding when agents should > be used or what an appropriate use of them would constitute, though.
When you need to update shared state, but you don't want to block the current thread. I'm looking at them to simplify request processing in network applications with lots of state machines. Agents let me write state machines in functional style with multi-methods dispatching on the current state and the type of input. I also don't have to write the code to put the messages on a queue and manage a thread pool myself. Nathan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---