Skip to content

Instantly share code, notes, and snippets.

@henrikengstrom
Created February 19, 2012 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrikengstrom/1863424 to your computer and use it in GitHub Desktop.
Save henrikengstrom/1863424 to your computer and use it in GitHub Desktop.
Shakespeare actor
def receive = {
case actors: Int =>
val futures = for (x <- 1 to actors) yield {
context.actorOf(Props[MonkeyWorker]) ? randomGenerator.nextInt(100) mapTo manifest[Set[String]]
}
Future.sequence(futures) map { wordSets =>
val mergedSet = wordSets reduce ( (a, b) => a ++ b )
val (shakespeare, unworthy) = mergedSet partition (x => Blueprint.contains(x))
Result(shakespeare, unworthy)
} pipeTo sender
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment