December 2015
Intermediate to advanced
298 pages
5h 30m
English
Akka is a Scala library, which let's us implement the message-based concurrency systems. An actor is like a small program with a message queue of its own. You can only get an actor to do some work by passing it a message.
Here is our FileFinder object as an actor:
import akka.actor._ import akka.util.Timeout import scala.io.Source object FileFinder { // 1 def props() = Props(new FileFinder) case class FileFinderMsg(pat: String, rootDir: String) } class FileFinder extends Actor { // 2 import FileFinder._ import context._ import java.io.File val grepActor = system.actorOf(Props(new GrepAFile), ""GrepAFile"") // 3 def recurseIntoDir(dir: File): Iterable[File] = { // 4 val itsChildren = new Iterable[File] { def ...
Read now
Unlock full access