Transactional collections
In this section, we take a step away from transactional references, and study more powerful transactional constructs, called, transactional collections. While transactional references can only hold a single value at once, transactional collections can manipulate multiple values. In principle, the atomic
statements and transactional references are sufficient to express any kind of transaction over shared data. However, ScalaSTM's transactional collections are deeply integrated with the STM. They can be used to express shared data operations more conveniently and execute the transactions more efficiently.
Transaction-local variables
We have already seen that some transactions need to create a local mutable state that exists only during the execution of the transaction. Sometimes, we need to re-declare the same state over and over again for multiple transactions. In such cases, we would like to declare the same state once, and reuse it in multiple transactions. A construct...