I have a main process that starts the process,by initiating worker actors and a master actor. Let me explain in the example
class process{
var q :collection.mutable.HashMap[]
var map:collection.mutable.HashMap[]
var itrator = q.grouped(1000)
//start master actor
var mas:Actor=null
mas = new Master(map)
mas.start
//start worker actors
var workActor :Actor = null
for(it<-itrator)
{
workActor = new Worker(map,mas)
workActor.start
}
}
class Worker(map:collection.mutable.HashMap[],master:Actor){
def act(){
//check for map size, break if it reaches n size
//pass the message to master to save the data
//then exit
//else
//start analysis process
//then exit
}
}
scenario 1: Once very worker actor is finished they inform the master actor,updating the count in the master actor . Once all the worker actors are finished,the MASTER actor will save the MAP.
Scenario 2: Once the size of the "map" reaches certain number,i want the worker actors to terminate and master actor shall save the data then terminate itself.
Issue: Currently after reaching n size in scenario 2,the worker actor terminates. But all the working actor terminates only after checking the n size condition. Is there way to communicate to all the currently working actors at same time to terminate after one worker reaches n size?