Merge branch 'master' of github.com:jboner/akka
This commit is contained in:
commit
8ad0f075aa
2 changed files with 28 additions and 2 deletions
|
|
@ -56,6 +56,8 @@ case class UnlinkAndStop(child: ActorRef) extends AutoReceivedMessage with LifeC
|
|||
|
||||
case object PoisonPill extends AutoReceivedMessage with LifeCycleMessage
|
||||
|
||||
case object Kill extends AutoReceivedMessage with LifeCycleMessage
|
||||
|
||||
case object ReceiveTimeout extends LifeCycleMessage
|
||||
|
||||
case class MaximumNumberOfRestartsWithinTimeRangeReached(
|
||||
|
|
@ -457,6 +459,7 @@ trait Actor {
|
|||
case Unlink(child) => self.unlink(child)
|
||||
case UnlinkAndStop(child) => self.unlink(child); child.stop
|
||||
case Restart(reason) => throw reason
|
||||
case Kill => throw new ActorKilledException("Kill")
|
||||
case PoisonPill =>
|
||||
val f = self.senderFuture
|
||||
self.stop
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import org.scalatest.matchers.MustMatchers
|
|||
import akka.testing._
|
||||
import akka.util.duration._
|
||||
import akka.testing.Testing.sleepFor
|
||||
|
||||
import akka.config.Supervision.{OneForOneStrategy}
|
||||
import akka.actor._
|
||||
import akka.dispatch.Future
|
||||
|
||||
import java.util.concurrent.{TimeUnit, CountDownLatch}
|
||||
|
||||
object ActorRefSpec {
|
||||
|
||||
|
|
@ -123,5 +123,28 @@ class ActorRefSpec extends WordSpec with MustMatchers {
|
|||
ref.isRunning must be (false)
|
||||
ref.isShutdown must be (true)
|
||||
}
|
||||
|
||||
"restart when Kill:ed" in {
|
||||
val latch = new CountDownLatch(2)
|
||||
|
||||
val boss = Actor.actorOf(new Actor{
|
||||
self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), scala.Some(2), scala.Some(1000))
|
||||
|
||||
val ref = Actor.actorOf(
|
||||
new Actor {
|
||||
def receive = { case _ => }
|
||||
override def preRestart(reason: Throwable) = latch.countDown
|
||||
override def postRestart(reason: Throwable) = latch.countDown
|
||||
}
|
||||
).start
|
||||
|
||||
self link ref
|
||||
|
||||
protected def receive = { case "sendKill" => ref ! Kill }
|
||||
}).start
|
||||
|
||||
boss ! "sendKill"
|
||||
latch.await(5, TimeUnit.SECONDS) must be === true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue