Had to revert back to synchronizing on actor when processing mailbox in dispatcher

This commit is contained in:
Jonas Bonér 2010-03-03 12:46:19 +01:00
parent 11cc8f2a22
commit d46504f72d
2 changed files with 7 additions and 14 deletions

View file

@ -62,22 +62,15 @@ class ExecutorBasedEventDrivenDispatcher(_name: String) extends MessageDispatche
def dispatch(invocation: MessageInvocation) = if (active) {
executor.execute(new Runnable() {
def run = {
var messageInvocation = invocation.receiver._mailbox.poll
while (messageInvocation != null) {
messageInvocation.invoke
messageInvocation = invocation.receiver._mailbox.poll
}
}
/* invocation.receiver.synchronized {
val messages = invocation.receiver._mailbox.iterator
while (messages.hasNext) {
messages.next.invoke
messages.remove
invocation.receiver.synchronized {
var messageInvocation = invocation.receiver._mailbox.poll
while (messageInvocation != null) {
messageInvocation.invoke
messageInvocation = invocation.receiver._mailbox.poll
}
}
}
*/
})
})
} else throw new IllegalStateException("Can't submit invocations to dispatcher since it's not started")
def start = if (!active) {

View file

@ -21,4 +21,4 @@ class AgentTest extends junit.framework.TestCase with Suite with MustMatchers wi
}
}
})
}
}