Actors for Squeak Smalltalk
Last updated at 4:19 am UTC on 11 August 2018
The Smalltalk-80 concurrency model is, at heart, threads with mutable shared state plus locks, semaphores, mutexes and so on (More: Squeak Threading Model).
The library adds an Erlang-style Actor model to Squeak.
The following code snippet creates an actor, and invokes one of its methods via synchronous (Promise-based) RPC:
h := HelloWorldActor spawn.
(h greet: 'Actor world') wait.
"produces 'Hello, Actor world!'"
Actors are concurrent Smalltalk objects.
Every Actor’s behavior is specified by a distinct behavior object, usually (but not always!) a subclass of ActorBehavior. Because Actor is a subclass of both ActorProcess and Process, it inherits the public interfaces of both.
The easiest way to learn the library is to try it out. There’s no substitute for experimentation in a live image!
The code snippets in the pages cannot be as interactive as the real thing. It can be difficult to get a feel for the system without hands-on experience. Install the system to try it out.