Hi Boris, > (doseq [e [retire-host slowdown-host infect-hosts naturalrecovery- > host pair-host breakup-host] i world] > (send-off (agent nil) (fn [_] (e i)))))) > > There doesn't seem to be any concurrency happening, and the whole > thing just slows down to not doing much at all.
This code will create potentially (count world) threads 10000. Just using send instead of send-off would possibly speed things up a lot as it will limit the number of threads. Also creating a new agent every time just to provide a thread is not economical. You could instead have a small pool of agents and reuse them. Or you could take advantage of futures which have been recently added to run the task without an agent at all: (doseq [e [r s i n b] i world] (future (e i))) Also you might consider using (comp) to compose the set of e into one function, which will reduce the amount of dispatches. Lastly, why do you say you have to use refs here? It isn't obvious to me from the code - the world locations look like they could be agents - but I'm probably missing something, its quite complex :) Regards, Tim. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---