我对两个actor,父P和子C进行了以下顺序操作:
> P手表C(背景手表c)
> P unwatches C(上下文unwatch c)
> P优雅地停止C(c!PoisonPill)
我想知道的是;我保证P不会收到C的终止事件吗?
这是一段代码示例
class HappensBefore extends App { class C extends Actor { def receive = {} } class P extends Actor { val c = context actorOf Props[C] context watch c context unwatch c c ! PoisonPill def receive = { case Terminated(child) => println("Oh Noes!") } } ActorSystem("test") actorOf Props[P] }
解决方法
不,没有这样的保证.