上下文切換
釋出 context.become(替換或新增新行為)的兩種可能方式是單獨提供的,以實現巢狀接收的無雜波符號:
val a = actor(new Act {
become { // this will replace the initial (empty) behavior
case "info" ⇒ sender() ! "A"
case "switch" ⇒
becomeStacked { // this will stack upon the "A" behavior
case "info" ⇒ sender() ! "B"
case "switch" ⇒ unbecome() // return to the "A" behavior
}
case "lobotomize" ⇒ unbecome() // OH NOES: Actor.emptyBehavior
}
})