In the preceding chapter, we discussed functional concurrency patterns using various code-examples. In this chapter, we will discuss actors patterns and functionality with the help of various code-examples.
In Chapter 1, Concurrency – An Introduction, we looked at two major paradigms for designing concurrent systems. The shared state paradigm requires careful state management. We provided reasons for using locks for safely sharing the state—we have to be aware of visibility and consistency issues.
Locking makes state manipulations atomic. However, this approach could result in locking bottlenecks. As an alternative, we took a look at lock-free data structures. However, lock-free structures are inherently complex.
In this chapter, we will take a look at the message-driven paradigm for creating concurrent programs. The shared state goes away. Instead, actors encapsulate the state, and the only way to change the state is via sending a message to it.