Knopflerfish OSGi 3.0.0

org.knopflerfish.util
Class Queue

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by org.knopflerfish.util.Queue
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess

public class Queue
extends java.util.Vector

The Queue class represents a first-in-first-out (FIFO) queue of objects.

Author:
Per Lundgren
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Queue(int size)
          Constructs an Queue with the specifies maximum size.
 
Method Summary
 void close()
          Closes the queue, i.e.
 void insert(java.lang.Object item)
          Inserts an item into the queue.
 void insertFirst(java.lang.Object item)
          Inserts an item first into the queue.
 java.lang.Object remove()
          Removes and returns the first object in the queue.
 java.lang.Object removeWait(float timeout)
          Removes and returns the first item in 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

Queue

public Queue(int size)
Constructs an Queue with the specifies maximum size.

Parameters:
size - maximum queue size.
Method Detail

insert

public void insert(java.lang.Object item)
            throws java.lang.IndexOutOfBoundsException
Inserts an item into the queue. If there are threads blocked on remove, one of them is unblocked.

Parameters:
item - the item to be inserted.
Throws:
java.lang.IndexOutOfBoundsException - if maximum queue size is reached.

insertFirst

public void insertFirst(java.lang.Object item)
Inserts an item first into the queue. If there are threads blocked on remove, one of them is unblocked.

Parameters:
item - the item to be inserted.

removeWait

public java.lang.Object removeWait(float timeout)
Removes and returns the first item in the queue. If the queue is empty, the calling thread will block.

Parameters:
timeout - timeout in seconds.
Returns:
The first item in the queue, or null if a timeout occurred. To distinguish timeouts, null items should not be inserted in the queue.

remove

public java.lang.Object remove()
Removes and returns the first object in the queue. Same as removeWait(float) but this function blocks forever.

Returns:
The first item in the queue.

close

public void close()
Closes the queue, i.e. wakes up all threads blocking on a call to remove() or removeWait(float).


Knopflerfish OSGi 3.0.0