|
|
|
|
|
by masklinn
5031 days ago
|
|
Pure values are not really relevant: you still need to update a binding somewhere to synchronize, and that's sufficient for your race. The clojure example wouldn't be safe if atoms weren't compare-and-set: have collection state A, thread one applies A->B, thread two applies A->C, the two threads set the atom (atomically but not CAS) and an increment has been lost even though all values are pure. |
|
In a functional language, the code would be:
where `!x` is referencing a transactional variable and `:=` is setting it.