com.android.builder.tasks
Class WorkQueue<T>

java.lang.Object
  extended by com.android.builder.tasks.WorkQueue<T>
All Implemented Interfaces:
java.lang.Runnable

public class WorkQueue<T>
extends java.lang.Object
implements java.lang.Runnable

A work queue that accepts jobs and treat them in order.


Constructor Summary
WorkQueue(com.android.utils.ILogger logger, QueueThreadContext<T> queueThreadContext, java.lang.String queueName, int workforce, int growthTriggerRatio)
          Creates a new queue, with a number of dedicated threads to process the queue's jobs.
 
Method Summary
 java.lang.String getName()
          Return a human readable queue name, mainly used for identification purposes.
 void push(Job<T> job)
           
 void run()
          each thread in the mWorkThreads will run this single infinite processing loop until a death action is received.
 void shutdown()
          Shutdowns the working queue and wait until all pending requests have been processed.
 int size()
          Returns the number of jobs waiting to be scheduled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkQueue

public WorkQueue(@NonNull
                 com.android.utils.ILogger logger,
                 @NonNull
                 QueueThreadContext<T> queueThreadContext,
                 @NonNull
                 java.lang.String queueName,
                 int workforce,
                 int growthTriggerRatio)
Creates a new queue, with a number of dedicated threads to process the queue's jobs.

Parameters:
logger - to log messages
queueName - a meaningful descriptive name.
workforce - the number of dedicated threads for this queue.
growthTriggerRatio - the ratio between outstanding requests and worker threads that should trigger a growth in worker threads.
Method Detail

push

public void push(Job<T> job)
          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

shutdown

public void shutdown()
              throws java.lang.InterruptedException
Shutdowns the working queue and wait until all pending requests have been processed. This needs to be reviewed as jobs can still be added to the queue once the shutdown process has started....

Throws:
java.lang.InterruptedException - if the shutdown sequence is interrupted

getName

public java.lang.String getName()
Return a human readable queue name, mainly used for identification purposes.

Returns:
a unique meaningful descriptive name

size

public int size()
Returns the number of jobs waiting to be scheduled.

Returns:
the size of the queue.

run

public void run()
each thread in the mWorkThreads will run this single infinite processing loop until a death action is received.

Specified by:
run in interface java.lang.Runnable