Adding support for completing senderFutures when actor is stopped, closing ticket #894. Also renaming DurableEventBasedDispatcher to DurableDispatcher

This commit is contained in:
Viktor Klang 2011-05-26 20:38:42 +02:00
parent e94b722a4b
commit 49883d8c59
8 changed files with 61 additions and 16 deletions

View file

@ -5,10 +5,9 @@
package akka.dispatch
import akka.event.EventHandler
import akka.actor.{ ActorRef }
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.{ TimeUnit, ExecutorService, RejectedExecutionException, ConcurrentLinkedQueue }
import akka.actor.{ ActorKilledException, ActorRef }
/**
* Default settings are:
@ -159,6 +158,21 @@ class Dispatcher(
private[akka] def reRegisterForExecution(mbox: MessageQueue with ExecutableMailbox): Unit =
registerForExecution(mbox)
protected override def cleanUpMailboxFor(actorRef: ActorRef) {
val m = getMailbox(actorRef)
if (!m.isEmpty) {
var invocation = m.dequeue
lazy val exception = new ActorKilledException("Actor has been stopped")
while (invocation ne null) {
val f = invocation.senderFuture
if (f.isDefined)
f.get.completeWithException(exception)
invocation = m.dequeue
}
}
}
override val toString = getClass.getSimpleName + "[" + name + "]"
def suspend(actorRef: ActorRef) {