Class PrioritizedThrottledTaskRunner<T extends AbstractRunnable & Comparable<T>>

java.lang.Object
org.elasticsearch.common.util.concurrent.PrioritizedThrottledTaskRunner<T>

public class PrioritizedThrottledTaskRunner<T extends AbstractRunnable & Comparable<T>> extends Object
PrioritizedThrottledTaskRunner performs the enqueued tasks in the order dictated by the natural ordering of the tasks, limiting the max number of concurrently running tasks. Each new task that is dequeued to be run, is forked off to the given executor.
  • Constructor Details

    • PrioritizedThrottledTaskRunner

      public PrioritizedThrottledTaskRunner(String name, int maxRunningTasks, Executor executor)
  • Method Details

    • enqueueTask

      public void enqueueTask(T task)
      Submits a task for execution. If there are fewer than maxRunningTasks tasks currently running then this task is immediately submitted to the executor. Otherwise this task is enqueued and will be submitted to the executor in turn on completion of some other task.
    • runningTasks

      public int runningTasks()
    • queueSize

      public int queueSize()