19 ms·
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 incre
by grayrest 17y ago
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?
- pmjordan 17y agoAgents launch the update function in a separate thread, which seems a bit much for incrementing a counter.
- grayrest 17y agoOne of these days I'll remember that agents aren't actors, just not today.
- ato 17y agoIndeed, 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.