Skip to content

Instantly share code, notes, and snippets.

@sstone
Created August 21, 2012 19:22
Show Gist options
  • Save sstone/3418498 to your computer and use it in GitHub Desktop.
Save sstone/3418498 to your computer and use it in GitHub Desktop.
using calculator actor
def compute(calc:ActorRef) {
implicit val timeout: Timeout = 5 second
for (x <- 0 to 5) {
for (y <-0 to 5) {
(calc ? AddRequest(x, y)).onComplete {
case Right(AddResponse(sum)) => println("%d + %d = %d".format(x, y, sum))
case Left(error) => println(error)
}
}
}
}
val system = ActorSystem("MySystem")
val calc = system.actorOf(Props[Calculator].withRouter(SmallestMailboxRouter(nrOfInstances = 8)))
compute(calc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment