News for hackers. Stuff that matters.
Re:Ongoing · Concur.next — Hard-Core Clojure by grayrest on Wednesday December 16, 2009 @10:01AM (#998875)
Any experienced Clojure people care to comment on why atoms were used instead of agents? You don't care when the counter is incremented, just that it gets incremented, so I'd assume that an agent would model the problem more closely. Is it an overhead thing or what?
Re:Ongoing · Concur.next — Hard-Core Clojure by pmjordan on Wednesday December 16, 2009 @10:42AM (#998957)
Agents launch the update function in a separate thread, which seems a bit much for incrementing a counter.
Re:Ongoing · Concur.next — Hard-Core Clojure by grayrest on Wednesday December 16, 2009 @02:39PM (#999561)
One of these days I'll remember that agents aren't actors, just not today.
Re:Ongoing · Concur.next — Hard-Core Clojure by ato on Wednesday December 16, 2009 @06:03PM (#999945)
Indeed, perhaps it would be a better way to model the problem, I considered it but perhaps rejected it incorrectly. By default Clojure uses a thread-pool for atoms so it wouldn't be a new thread for each request, the overhead is just a queue push which is not that great. It would mean serializing all the updates, but you could use fine-grained agents like I'm using fine-grained atoms.