Thread confinement works fine for the scenario mentioned previously, but say that we need a way to scale it for scenarios in which we need to modify the shared state from many different parts of the app, or if we want more flexibility on our atomic block. For more complicated scenarios, we can build upon the idea of thread confinement and improve our solution by using a concurrency primitive that we saw before: channels. By mixing both of them we can create an actor.
Actors
What is an actor?
Actors are a combination of two powerful tools: we can confine the accesses of a state to a single thread and allow other threads to request modifications to the state using channels. This way, we have not only a safe way to update the...