News for hackers. Stuff that matters.
Re:Clojure – Fascinated, Disappointed, Astonished (2016) by reitzensteinm on Friday January 24, 2020 @04:46PM (#22142779)
Clojure generally uses CAS semantics, although it also has transactions that can update multiple refs atomically. So nothing is ever "silently overwritten" and there's no locking required, it's all optimistic concurrency.

However, to agree with part of your point, an atom being updated with CAS can only ever progress linearly; if you bang 8 threads in a loop trying to update it, you might as well use a lock, because 7/8 of the work is going to be thrown out.

They should only be used for cases where on average one thread or less is working on updating it; anything more, and it needs to be split, the problem rethought, or some mechanism for not throwing out wasted work implemented.

It's not a silver bullet.

There are no comments on this comment yet.