Apache Tomcat 7.0.27

org.apache.tomcat.util.threads
Class TaskQueue

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by java.util.concurrent.LinkedBlockingQueue<java.lang.Runnable>
              extended by org.apache.tomcat.util.threads.TaskQueue
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<java.lang.Runnable>, java.util.Collection<java.lang.Runnable>, java.util.concurrent.BlockingQueue<java.lang.Runnable>, java.util.Queue<java.lang.Runnable>

public class TaskQueue
extends java.util.concurrent.LinkedBlockingQueue<java.lang.Runnable>

As task queue specifically designed to run with a thread pool executor. The task queue is optimised to properly utilize threads within a thread pool executor. If you use a normal queue, the executor will spawn threads when there are idle threads and you wont be able to force items unto the queue itself

Author:
fhanik
See Also:
Serialized Form

Constructor Summary
TaskQueue()
           
TaskQueue(java.util.Collection<? extends java.lang.Runnable> c)
           
TaskQueue(int capacity)
           
 
Method Summary
 boolean force(java.lang.Runnable o)
           
 boolean force(java.lang.Runnable o, long timeout, java.util.concurrent.TimeUnit unit)
           
 boolean offer(java.lang.Runnable o)
           
 java.lang.Runnable poll(long timeout, java.util.concurrent.TimeUnit unit)
           
 int remainingCapacity()
           
 void setForcedRemainingCapacity(java.lang.Integer forcedRemainingCapacity)
           
 void setParent(ThreadPoolExecutor tp)
           
 java.lang.Runnable take()
           
 
Methods inherited from class java.util.concurrent.LinkedBlockingQueue
clear, drainTo, drainTo, iterator, offer, peek, poll, put, remove, size, toArray, toArray, toString
 
Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, removeAll, retainAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.BlockingQueue
add, contains
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll
 

Constructor Detail

TaskQueue

public TaskQueue()

TaskQueue

public TaskQueue(int capacity)

TaskQueue

public TaskQueue(java.util.Collection<? extends java.lang.Runnable> c)
Method Detail

setParent

public void setParent(ThreadPoolExecutor tp)

force

public boolean force(java.lang.Runnable o)

force

public boolean force(java.lang.Runnable o,
                     long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

offer

public boolean offer(java.lang.Runnable o)
Specified by:
offer in interface java.util.concurrent.BlockingQueue<java.lang.Runnable>
Specified by:
offer in interface java.util.Queue<java.lang.Runnable>
Overrides:
offer in class java.util.concurrent.LinkedBlockingQueue<java.lang.Runnable>

poll

public java.lang.Runnable poll(long timeout,
                               java.util.concurrent.TimeUnit unit)
                        throws java.lang.InterruptedException
Specified by:
poll in interface java.util.concurrent.BlockingQueue<java.lang.Runnable>
Overrides:
poll in class java.util.concurrent.LinkedBlockingQueue<java.lang.Runnable>
Throws:
java.lang.InterruptedException

take

public java.lang.Runnable take()
                        throws java.lang.InterruptedException
Specified by:
take in interface java.util.concurrent.BlockingQueue<java.lang.Runnable>
Overrides:
take in class java.util.concurrent.LinkedBlockingQueue<java.lang.Runnable>
Throws:
java.lang.InterruptedException

remainingCapacity

public int remainingCapacity()
Specified by:
remainingCapacity in interface java.util.concurrent.BlockingQueue<java.lang.Runnable>
Overrides:
remainingCapacity in class java.util.concurrent.LinkedBlockingQueue<java.lang.Runnable>

setForcedRemainingCapacity

public void setForcedRemainingCapacity(java.lang.Integer forcedRemainingCapacity)

Apache Tomcat 7.0.27

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.