2 Up and running
This chapter covers
- Sending messages
- Behaviors as first-class citizen
- Creating new Actors
- Sending a message and expecting a response
- Timers
- Some Tips
Let's start from the beginning. Long ago, the Fathers of the Actor Model gave three abilities to its Actors:
- Send a finite number of messages to other Actors
- Create a finite number of new Actors
- Designate the behavior to be used for the next message it receives
These are the three things that an actor can do upon receiving a message. There is not an assumed order in these actions, and they could be carried concurrently, which means interleaved with no prescribed order. You may also think of it as combined without repetition. When receiving a message, you may reason as if nothing else happens in the whole system. You would do some processing, maybe some storage, some communication, and in the end, you’d designate the next behavior. That’s it. An actor does one thing at a time, one message at a time.
Why finite you may ask? The actor can only process one message at a time if it never stops sending messages or creating actors. When will it get the chance to process the next message?
Yep. Never again.
It’s also important to bear in mind that an Actor, as the fundamental unit of computation, has to embody three things. It has to be able to process, store, and communicate. We'll see all of these in the samples, of course. Sending messages