private void Terminate()
{
SetReceiveTimeout(null);
CancelReceiveTimeout();
// prevent Deadletter(Terminated) messages
UnwatchWatchedActors(_actor);
StopChildren();
//TODO: Implement when we have ActorSystem.Abort
// if (systemImpl.aborting) {
// // separate iteration because this is a very rare case that should not penalize normal operation
// children foreach {
// case ref: ActorRefScope if !ref.isLocal ⇒ self.sendSystemMessage(DeathWatchNotification(ref, true, false))
// case _ ⇒
// }
// }
var wasTerminating = IsTerminating;
if (SetChildrenTerminationReason(SuspendReason.Termination.Instance))
{
if (!wasTerminating)
{
// do not process normal messages while waiting for all children to terminate
SuspendNonRecursive();
// do not propagate failures during shutdown to the supervisor
SetFailed(_self);
if (System.Settings.DebugLifecycle)
Publish(new Debug(_self.Path.ToString(), ActorType, "Stopping"));
}
}
else
{
SetTerminated();
FinishTerminate();
}
}