Created
August 21, 2012 19:22
-
-
Save sstone/3418498 to your computer and use it in GitHub Desktop.
using calculator actor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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