Fixing race-conditions, now works albeit inefficiently when adding/removing actors rapidly
This commit is contained in:
parent
594efe9464
commit
b80fb9096a
6 changed files with 32 additions and 26 deletions
|
|
@ -9,8 +9,7 @@ import java.util.concurrent._
|
|||
import atomic.{AtomicLong, AtomicInteger}
|
||||
import ThreadPoolExecutor.CallerRunsPolicy
|
||||
|
||||
import se.scalablesolutions.akka.actor.IllegalActorStateException
|
||||
import se.scalablesolutions.akka.util. {Duration, Logger, Logging}
|
||||
import se.scalablesolutions.akka.util. {Duration, Logging}
|
||||
|
||||
object ThreadPoolConfig {
|
||||
type Bounds = Int
|
||||
|
|
@ -194,7 +193,7 @@ class MonitorableThread(runnable: Runnable, name: String)
|
|||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
class BoundedExecutorDecorator(val executor: ExecutorService, bound: Int) extends ExecutorServiceDelegate with Logging {
|
||||
class BoundedExecutorDecorator(val executor: ExecutorService, bound: Int) extends ExecutorServiceDelegate {
|
||||
protected val semaphore = new Semaphore(bound)
|
||||
|
||||
override def execute(command: Runnable) = {
|
||||
|
|
@ -219,7 +218,7 @@ class BoundedExecutorDecorator(val executor: ExecutorService, bound: Int) extend
|
|||
}
|
||||
}
|
||||
|
||||
trait ExecutorServiceDelegate extends ExecutorService {
|
||||
trait ExecutorServiceDelegate extends ExecutorService with Logging {
|
||||
|
||||
def executor: ExecutorService
|
||||
|
||||
|
|
@ -254,7 +253,10 @@ trait LazyExecutorService extends ExecutorServiceDelegate {
|
|||
|
||||
def createExecutor: ExecutorService
|
||||
|
||||
lazy val executor = createExecutor
|
||||
lazy val executor = {
|
||||
log.info("Lazily initializing ExecutorService for ",this)
|
||||
createExecutor
|
||||
}
|
||||
}
|
||||
|
||||
class LazyExecutorServiceWrapper(executorFactory: => ExecutorService) extends LazyExecutorService {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue