Skip to content

Instantly share code, notes, and snippets.

@worthlesscog
Created May 13, 2012 19:24
Show Gist options
  • Save worthlesscog/2689856 to your computer and use it in GitHub Desktop.
Save worthlesscog/2689856 to your computer and use it in GitHub Desktop.
Decimal number reader and splitter
import scala.actors.remote.RemoteActor.select
import scala.actors.remote.Node
import scala.actors.Actor
object Reader {
def main(args: Array[String]) {
println("Reader running")
val actor = new Actor {
def act() {
val mappers = System.getProperty("mappers").split(",").map(m ⇒ select(Node("localhost", m.toInt), 'mapper))
var n = System.getProperty("number").toInt
var m = 0
do {
mappers(m % mappers.size) ! (m, n % 1000)
m += 1
n /= 1000
} while (n > 0)
mappers.foreach(_ ! "Done")
}
}
actor.start
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment