Created
May 13, 2012 19:51
-
-
Save worthlesscog/2689928 to your computer and use it in GitHub Desktop.
Collect the numbered chunks for reassembly
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
import scala.actors.Actor.self | |
import scala.actors.remote.RemoteActor.{ register, alive } | |
import scala.actors.Actor | |
import scala.collection.immutable.TreeMap | |
import scala.collection.mutable.Map | |
object Reducer { | |
def main(args: Array[String]) { | |
println("Reducer running") | |
val actor = new Actor { | |
def act { | |
alive(System.getProperty("port").toInt) | |
register('reducer, self) | |
var results = System.getProperty("results").toInt | |
println("Expecting " + results + " result(s)") | |
var map = TreeMap[Int, String]() | |
while (results > 0) { | |
receive { | |
case m: Map[Int, String] ⇒ println("Received " + m); map ++= m; results -= 1 | |
} | |
} | |
println("Results " + map) | |
} | |
} | |
actor.start | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment