org.jboss.threads
Class OrderedExecutor

java.lang.Object
  extended by org.jboss.threads.OrderedExecutor
All Implemented Interfaces:
java.util.concurrent.Executor

public final class OrderedExecutor
extends java.lang.Object
implements java.util.concurrent.Executor

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 Summary
OrderedExecutor(java.util.concurrent.Executor parent)
          Construct a new instance using an unbounded FIFO queue.
OrderedExecutor(java.util.concurrent.Executor parent, java.util.Queue<java.lang.Runnable> queue)
          Construct a new instance using the given queue and a blocking reject policy.
OrderedExecutor(java.util.concurrent.Executor parent, java.util.Queue<java.lang.Runnable> queue, RejectionPolicy policy, java.util.concurrent.Executor handoffExecutor)
          Construct a new instance.
OrderedExecutor(java.util.concurrent.Executor parent, RejectionPolicy policy, java.util.concurrent.Executor handoffExecutor)
          Construct a new instance using an unbounded FIFO queue.
 
Method Summary
 void execute(java.lang.Runnable command)
          Run a task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderedExecutor

public OrderedExecutor(java.util.concurrent.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(java.util.concurrent.Executor parent,
                       java.util.Queue<java.lang.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(java.util.concurrent.Executor parent,
                       RejectionPolicy policy,
                       java.util.concurrent.Executor handoffExecutor)
Construct a new instance using an unbounded FIFO queue.

Parameters:
parent - the parent executor
policy - the task rejection policy
handoffExecutor - the executor to hand tasks to if the queue is full

OrderedExecutor

public OrderedExecutor(java.util.concurrent.Executor parent,
                       java.util.Queue<java.lang.Runnable> queue,
                       RejectionPolicy policy,
                       java.util.concurrent.Executor handoffExecutor)
Construct a new instance.

Parameters:
parent - the parent executor
queue - the task queue to use
policy - the task rejection policy
handoffExecutor - the executor to hand tasks to if the queue is full
Method Detail

execute

public void execute(java.lang.Runnable command)
Run a task.

Specified by:
execute in interface java.util.concurrent.Executor
Parameters:
command - the task to run.


Copyright © 2011. All Rights Reserved.