1
votes

This earlier question suggests that calling 'stop' on a supervisor actor will shut down all linked actors. However, if one creates a 'custom' actor (not through a factory), it seems that this auto-shutdown doesn't happen. For example, see this code from the answer to another question:

class Module1 extends Actor {
   self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), 5, 5000)

   def receive = {
       case Register(actor) =>
           self.link(actor)
   }
}

If 'stop' was called on the above Module1 actor, the actors linked to it wouldn't shut down. Is there a way to make a custom actor automatically shut down linked actors? Or is this just something that you have to write yourself if you want to create a custom actor?

Thanks!

1

1 Answers

2
votes

You can call:

self.linkedActors.values.iterator

and then send a PoisonPill or stop() them.