org.omegahat.Environment.TaskManagement
Class TaskQueue

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--org.omegahat.Environment.TaskManagement.TaskQueue
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable
Direct Known Subclasses:
DistributedTaskQueue

public class TaskQueue
extends java.util.Vector

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
TaskQueue()
          Default constructor that takes the initial capacity from the default Vector constructor.
TaskQueue(int size)
          Construct an empty queue with initial capacity specified by the given size.
TaskQueue(Task t)
          Create and populate with a single task.
TaskQueue(Task[] arr)
          Create and populate with Task objects specified in the array.
TaskQueue(java.util.Vector arr)
          Create and populate with Tasks gather in the specified Vector.
 
Method Summary
 int addTask(Task t)
          Add an individual task.
 int addTask(Task t, boolean notify)
          Add a new Task at the end of the queue and conditionally notify waiting threads.
 Task getTask()
          Retrieves a single element from the queue, and removes it.
 Task getTask(boolean consume, boolean block)
          Obtain a Task from the top (beginning) of the queue.
 TaskQueue tasks()
          Obtain are reference to this TaskQueue.
 TaskQueue tasks(Task[] arr)
          Augment the contents of the queue with the given Task objects
 TaskQueue tasks(java.util.Vector v)
          Add the specified tasks to the current contents of the queue.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

TaskQueue

public TaskQueue()
Default constructor that takes the initial capacity from the default Vector constructor.

TaskQueue

public TaskQueue(int size)
Construct an empty queue with initial capacity specified by the given size.

TaskQueue

public TaskQueue(Task[] arr)
Create and populate with Task objects specified in the array.

TaskQueue

public TaskQueue(java.util.Vector arr)
Create and populate with Tasks gather in the specified Vector.

TaskQueue

public TaskQueue(Task t)
Create and populate with a single task.
Method Detail

tasks

public TaskQueue tasks()
Obtain are reference to this TaskQueue.

tasks

public TaskQueue tasks(Task[] arr)
Augment the contents of the queue with the given Task objects

tasks

public TaskQueue tasks(java.util.Vector v)
Add the specified tasks to the current contents of the queue.

addTask

public int addTask(Task t)
Add an individual task. Notify waiting threads that a new element has been added.

addTask

public int addTask(Task t,
                   boolean notify)
Add a new Task at the end of the queue and conditionally notify waiting threads. The benefit of not notifying is when one is adding multiple tasks in a loop and wishes to wait until all the tasks have been added. The final call to this method would pass the value `true' in this case, and `false' for the first n-1 calls.

getTask

public Task getTask()
Retrieves a single element from the queue, and removes it. If there are no elements on the queue, this waits until another thread adds one.

getTask

public Task getTask(boolean consume,
                    boolean block)
Obtain a Task from the top (beginning) of the queue. This optionally returns immediately if there are no elements in the queue. This is controlled by the