Actor Model and CSP
In the previous chapters we reached for tools like mutexes, atomics, and futures to protect shared state and coordinate the order in which threads run. But shared memory plus locks is just one paradigm of concurrent programming — another school argues for "don't share memory at all", replacing locks with message passing.
In this chapter we dig into two "share-nothing" concurrency models: the Actor model and CSP (Communicating Sequential Processes). The Actor model, proposed by Carl Hewitt in 1973, organizes concurrency around Actors that have identity and communicate through asynchronous message passing; it has been validated at industrial scale in Erlang and Akka. CSP, proposed by Tony Hoare in 1978, connects independent sequential processes through anonymous channels — Go's goroutine + channel is its classic implementation.
Using C++, we will build the core components of an Actor framework (mailbox, message loop, supervisor) and a Go-style channel pipeline (buffered/unbuffered, close semantics, select) from scratch, understand the design motivations and implementation principles behind them, and discuss how to choose the right concurrency abstraction in a real project.