September 2015
Intermediate to advanced
250 pages
6h 40m
English
You typically create objects and invoke methods on them. An actor is also an object, but you never call methods on it directly. Instead you send messages and each actor is backed by a message queue. If an actor is busy processing a message, then the messages that arrive are queued—the senders aren’t blocked; they fire-and-forget. At most, one message is processed on an actor at any given time. Actors are born and built with thread safety.
Let’s define an actor.
| ProgrammingActors/HollywoodActor.scala | |
| | import akka.actor._ |
| | |
| | class HollywoodActor() extends Actor { |
| | def receive = { |
| | case message => println(s"playing the role of $message") |
| | } |
| | } |
Scala uses actors from Akka—a very powerful reactive library written in ...
Read now
Unlock full access