Actor model¶
Category: Communication · Status: stub · Lessons: chapter 05, Message passing (planned)
One line: Actors are isolated units with a mailbox: each handles one message at a time, and can send messages, create actors and change its own state.
Also called: actors, mailbox.
How it connects¶
flowchart LR
n_actor_model["Actor model"]
n_csp["Communicating sequential processes"]
n_message_passing["Message passing"]
n_otp_behaviours["OTP behaviours"]
n_supervision["Supervision"]
n_actor_model ---|vs| n_csp
n_actor_model -->|is a| n_message_passing
n_otp_behaviours -->|uses| n_actor_model
n_supervision -->|uses| n_actor_model
classDef center stroke-width:3px
class n_actor_model center
classDef outside stroke-dasharray: 4 3
class n_csp,n_message_passing,n_otp_behaviours,n_supervision outside
- Is a kind of: Message passing
- Is used by: OTP behaviours, Supervision
- Often confused with: Communicating sequential processes
- See also: Concurrency models
In each language¶
| C# | Orleans ↗, whose virtual actors are called grains |
| Kotlin | the channel-based actor ↗ builder is marked @ObsoleteCoroutinesApi |
| Swift | an actor ↗ is a reference type that lets only one task at a time access its mutable state |
| Erlang and Elixir | processes are the actors, each with a mailbox it reads with receive (Elixir ↗); a GenServer ↗ is a process that keeps state and serves calls |
| Elsewhere | Akka ↗: an actor processes one message at a time, so its state needs no locks |
Where to read more¶
- In the books: Async Rust, Maxwell Flitton, Caroline Morton — ch. 8, 'The Actor Model'
- In the books: Learning Concurrent Programming in Scala, Aleksandar Prokopec — ch. 8, 'Actors'
- In the books: Kotlin Coroutines by Tutorials, Filip Babić, Nishant Srivastava — ch. 13, 'Producer & Actors'
- In the books: Seven Concurrency Models in Seven Weeks, Paul Butcher — ch. 5, 'Actors'
- In the books: Programming Concurrency on the JVM, Venkat Subramaniam — ch. 8, 'Favoring Isolated Mutability' → 'Isolating Mutability Using Actors'
- In the books: The Little Elixir & OTP Guidebook, Benjamin Tan Wei Hao — ch. 3, 'Processes 101' → 'Actor concurrency model'
- Notes: actors model ↗
- Reference: Wikipedia: Actor model ↗