com.twitter.common.util
Class QueueDrainer<T extends Runnable>

java.lang.Object
  extended by com.twitter.common.util.QueueDrainer<T>
All Implemented Interfaces:
Runnable

public class QueueDrainer<T extends Runnable>
extends Object
implements Runnable

Joins a task queue with an executor service, to add control over when tasks are actually made available for execution.


Constructor Summary
QueueDrainer(Executor taskExecutor, BlockingQueue<T> blockingQueue)
          Creates a QueueDrainer that associates the queue with an executorService.
 
Method Summary
 void run()
          Picks tasks from the Queue to execute if present else no-op.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueDrainer

public QueueDrainer(Executor taskExecutor,
                    BlockingQueue<T> blockingQueue)
Creates a QueueDrainer that associates the queue with an executorService.

Parameters:
taskExecutor - Executor to execute a task if present.
blockingQueue - Queue to poll if there is a runnable to execute.
Method Detail

run

public void run()
Picks tasks from the Queue to execute if present else no-op.

Specified by:
run in interface Runnable