remove 1 synchronized from akka.dispatch
This commit is contained in:
parent
b52c498638
commit
f4e6443f7e
1 changed files with 7 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ import akka.dispatch.sysmsg.SystemMessage
|
|||
import java.util.concurrent.{ ExecutorService, RejectedExecutionException }
|
||||
import scala.concurrent.duration.Duration
|
||||
import scala.concurrent.duration.FiniteDuration
|
||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
|
||||
/**
|
||||
* The event-based ``Dispatcher`` binds a set of Actors to a thread pool backed up by a
|
||||
|
|
@ -88,16 +89,17 @@ class Dispatcher(
|
|||
new Mailbox(mailboxType.create(Some(actor.self), Some(actor.system))) with DefaultSystemMessageQueue
|
||||
}
|
||||
|
||||
private val esUpdater = AtomicReferenceFieldUpdater.newUpdater(
|
||||
classOf[Dispatcher],
|
||||
classOf[LazyExecutorServiceDelegate],
|
||||
"executorServiceDelegate")
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
protected[akka] def shutdown: Unit = {
|
||||
val newDelegate = executorServiceDelegate.copy() // Doesn't matter which one we copy
|
||||
val es = synchronized {
|
||||
val service = executorServiceDelegate
|
||||
executorServiceDelegate = newDelegate // just a quick getAndSet
|
||||
service
|
||||
}
|
||||
val es = esUpdater.getAndSet(this, newDelegate)
|
||||
es.shutdown()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue