Created
February 19, 2012 11:54
-
-
Save henrikengstrom/1863424 to your computer and use it in GitHub Desktop.
Shakespeare actor
This file contains hidden or 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 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