Clojure’s Solution
Clojure’s immutable data structures, managed reference types, and software transactional memory system combine to provide a model that’s both high level and much easier to use than locking concurrency. Let’s dig in with a look at an atom, which I find to be the simplest to understand of the reference types Clojure provides.
Atomic Power
As we saw in Chapter 8, Identity, Value, and State in Clojure, atoms are good for managing state that’s independent and to which we want to make synchronous changes. Here, independent means we can make the change without coordinating a change to any other piece of state. Synchronous means we want to block the thread that triggered the change until it’s done.
We can create an atom out of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access