From 4e960e536433a8ab09c07b41cf6dc5c657a869b3 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 17 Oct 2011 19:33:19 +0200 Subject: [PATCH] Changing so that the mailbox status is ack:ed after the _whole_ processing of the current batch, which means that Akka only does 1 volatile write per batch (of course the backing mailboxes might do their own volatile writes) --- akka-actor/src/main/scala/akka/actor/ActorCell.scala | 4 ---- akka-actor/src/main/scala/akka/dispatch/Mailbox.scala | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/akka-actor/src/main/scala/akka/actor/ActorCell.scala b/akka-actor/src/main/scala/akka/actor/ActorCell.scala index 1d46a48623..30f82e975f 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorCell.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorCell.scala @@ -443,8 +443,6 @@ private[akka] class ActorCell( app.eventHandler.error(e, self, "error while processing " + envelope.message) //TODO FIXME How should problems here be handled? throw e - } finally { - mailbox.acknowledgeStatus() //Volatile write } } @@ -487,8 +485,6 @@ private[akka] class ActorCell( messageHandle.channel sendException new ActorKilledException("Actor has been stopped") // throwing away message if actor is shut down, no use throwing an exception in receiving actor's thread, isShutdown is enforced on caller side } - } finally { - mailbox.acknowledgeStatus() } } diff --git a/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala b/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala index 89f5c9bb62..5e21d5ea87 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala @@ -128,7 +128,10 @@ abstract class Mailbox extends AbstractMailbox with MessageQueue with SystemMess */ if (s >= Scheduled) { updateStatus(s, s & ~Scheduled) || setAsIdle() - } else false + } else { + acknowledgeStatus() // this write is needed to make memory consistent after processMailbox() + false + } } def shouldBeRegisteredForExecution(hasMessageHint: Boolean, hasSystemMessageHint: Boolean): Boolean = status match {