Class OrderedExecutor

All Implemented Interfaces:
Executor, ExecutorService, BlockingExecutor, BlockingExecutorService

public final class OrderedExecutor extends AbstractExecutorService implements BlockingExecutorService
An executor that always runs all tasks in queue order, using a delegate executor to run the tasks.

More specifically, if a FIFO queue type is used, any call B to the execute(Runnable) method that happens-after another call A to the same method, will result in B's task running after A's.

  • Constructor Details

    • OrderedExecutor

      public OrderedExecutor(Executor parent)
      Construct a new instance using an unbounded FIFO queue. Since the queue is unbounded, tasks are never rejected.
      Parameters:
      parent - the parent to delegate tasks to
    • OrderedExecutor

      public OrderedExecutor(Executor parent, Queue<Runnable> queue)
      Construct a new instance using the given queue and a blocking reject policy.
      Parameters:
      parent - the parent to delegate tasks to
      queue - the queue to use to hold tasks
    • OrderedExecutor

      public OrderedExecutor(Executor parent, int queueLength)
      Construct a new instance using a bounded FIFO queue of the given size and a blocking reject policy.
      Parameters:
      parent - the parent to delegate tasks to
      queueLength - the fixed length of the queue to use to hold tasks
    • OrderedExecutor

      public OrderedExecutor(Executor parent, int queueLength, Executor handoffExecutor)
      Construct a new instance using a bounded FIFO queue of the given size and a handoff reject policy.
      Parameters:
      parent - the parent executor
      queueLength - the fixed length of the queue to use to hold tasks
      handoffExecutor - the executor to hand tasks to if the queue is full
    • OrderedExecutor

      public OrderedExecutor(Executor parent, Queue<Runnable> queue, boolean blocking, Executor handoffExecutor)
      Construct a new instance.
      Parameters:
      parent - the parent executor
      queue - the task queue to use
      blocking - true if rejected tasks should block, false if rejected tasks should be handed off
      handoffExecutor - the executor to hand tasks to if the queue is full
    • OrderedExecutor

      public OrderedExecutor(Executor parent, int queueLength, boolean blocking, Executor handoffExecutor)
      Construct a new instance using a bounded FIFO queue of the given size and a handoff reject policy.
      Parameters:
      parent - the parent executor
      queueLength - the fixed length of the queue to use to hold tasks
      blocking - true if rejected tasks should block, false if rejected tasks should be handed off
      handoffExecutor - the executor to hand tasks to if the queue is full
  • Method Details