Adding Pi2, fixing router shutdown in Pi, cleaning up the generation of workers in Pi
This commit is contained in:
parent
64d620c7b1
commit
c14c01a53c
2 changed files with 135 additions and 5 deletions
|
|
@ -66,11 +66,7 @@ object Pi {
|
|||
var start: Long = _
|
||||
|
||||
// create the workers
|
||||
val workers = {
|
||||
var ws = Vector[ActorRef]()
|
||||
for (i <- 0 until nrOfWorkers) ws = ws :+ actorOf[Worker].start
|
||||
ws
|
||||
}
|
||||
val workers = Vector.fill(nrOfWorkers)(actorOf[Worker].start)
|
||||
|
||||
// wrap them with a load-balancing router
|
||||
val router = Routing.loadBalancerActor(CyclicIterator(workers)).start
|
||||
|
|
@ -84,6 +80,9 @@ object Pi {
|
|||
// send a PoisonPill to all workers telling them to shut down themselves
|
||||
router ! Broadcast(PoisonPill)
|
||||
|
||||
// send a PoisonPill to the router, telling him to shut himself down
|
||||
router ! PoisonPill
|
||||
|
||||
case Result(value) =>
|
||||
// handle result from the worker
|
||||
pi += value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue