Appendix 1Clojure Agents

Clojure agents[24] represent a single identity or location in memory. Recollect that STM’s refs manage coordinated synchronous changes to multiple identities. Agents allow independent asynchronous changes to the individual identities they manage. The changes are expressed in the form of functions or actions that are applied to that location asynchronously. Multiple independent concurrent actions are run in sequence, one after the other. Upon successful completion of an action, an agent is changed to the new state returned by the action. This new state is used for subsequent reads or subsequent actions on the agent.

The calls to run actions on an agent return immediately. The action is then applied on the agent using ...

Get Programming Concurrency on the JVM now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.