def createBoundedExecutorService()

in cassovary-core/src/main/scala/com/twitter/cassovary/util/ExecutorUtils.scala [72:93]


  def createBoundedExecutorService(name: String,
                                   maxWorkQueueDepth: Int,
                                   minThreads: Int,
                                   maxThreads: Int,
                                   maxIdleTime: Duration)
                                  (rejectedExecutionHandler: => Unit): ExecutorService = {

    val taskQueue = new LinkedBlockingQueue[Runnable](maxWorkQueueDepth)

    val threadPoolExecutor = new ThreadPoolExecutor(
        minThreads,
        maxThreads,
        maxIdleTime.inMillis,
        TimeUnit.MILLISECONDS,
        taskQueue,
        createThreadFactory(name),
        rejectedExecutionHandlerFactory(name, rejectedExecutionHandler))
    statsReceiver.addGauge(name + "_queue_depth") { taskQueue.size }
    createPoolStats(name, threadPoolExecutor)

    threadPoolExecutor
  }