Fixing (yes, I know, I've said this a biiiiiillion times) the BalancingDispatcher, removing some wasteful volatile reads in the hot path
This commit is contained in:
parent
069c68f6d4
commit
9ae3d7feba
7 changed files with 106 additions and 115 deletions
|
|
@ -107,20 +107,16 @@ class Dispatcher(
|
|||
|
||||
protected[akka] def createMailbox(actor: ActorCell): Mailbox = mailboxType.create(actor)
|
||||
|
||||
protected[akka] def shutdown {
|
||||
executorService.getAndSet(new ExecutorServiceDelegate {
|
||||
protected[akka] def shutdown: Unit =
|
||||
Option(executorService.getAndSet(new ExecutorServiceDelegate {
|
||||
lazy val executor = executorServiceFactory.createExecutorService
|
||||
}) match {
|
||||
case null ⇒
|
||||
case some ⇒ some.shutdown()
|
||||
}
|
||||
}
|
||||
})) foreach { _.shutdown() }
|
||||
|
||||
/**
|
||||
* Returns if it was registered
|
||||
*/
|
||||
protected[akka] override def registerForExecution(mbox: Mailbox, hasMessageHint: Boolean, hasSystemMessageHint: Boolean): Boolean = {
|
||||
if (mbox.shouldBeScheduledForExecution(hasMessageHint, hasSystemMessageHint)) { //This needs to be here to ensure thread safety and no races
|
||||
if (mbox.canBeScheduledForExecution(hasMessageHint, hasSystemMessageHint)) { //This needs to be here to ensure thread safety and no races
|
||||
if (mbox.setAsScheduled()) {
|
||||
try {
|
||||
executorService.get() execute mbox
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue