All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class iBus.FIFOQueue

java.lang.Object
   |
   +----iBus.FIFOQueue

public class FIFOQueue
extends Object
Bounded, prioritized FIFO queue. A FIFOQueue has a maximum capacity. Once the capacity is reached, the next ``put'' operation blocks until ``get'' is called. A priority 1..n can be assigned to an object when it is put into the queue. A get operation always returns the highest priority objects first.


Constructor Index

 o FIFOQueue(int)
Create a FIFOQueue with a certain maximum capacity and with one priority level.
 o FIFOQueue(int, int)
Create a FIFOQueue with a certain maximum capacity.

Method Index

 o get()
Remove the object that has the highest priority.
 o getCapacity()
Returns the capacity of the queue.
 o getPriorities()
Returns the number of priorities.
 o isBounded()
Checks whether the capacity of the queue has an upper bound.
 o put(Object)
Put an object into the queue.
 o put(Object, int)
Put an object into the queue for a given priority.
 o size()
Returns the total number of events in the queue.
 o tryGet()
Like ``get'' but non-blocking.
 o waitTillEmpty()
Block until the queue is empty

Constructors

 o FIFOQueue
 public FIFOQueue(int maxCapacity)
Create a FIFOQueue with a certain maximum capacity and with one priority level.

Parameters:
maxCapacity - the maximum number of objects that can be put into the queue without blocking the thread that calls put. A maxCapacity of -1 indicated infinite capacity.
 o FIFOQueue
 public FIFOQueue(int maxCapacity,
                  int numPriorities)
Create a FIFOQueue with a certain maximum capacity.

Parameters:
maxCapacity - the maximum number of objects that can be put into the queue without blocking the thread that calls put. A maxCapacity of -1 indicated infinite capacity.
numPriorities - the number of priority levels to support.

Methods

 o put
 public void put(Object o)
Put an object into the queue. Blocks the caller if there are maxCapacity objects in the queue.

Parameters:
o - the object to put into the queue
 o put
 public synchronized void put(Object o,
                              int prio)
Put an object into the queue for a given priority. Blocks the caller if there are maxCapacity objects in the queue.

Parameters:
o - the object to put into the queue
prio - the priority of the object ( > 0 ). 1 is the highest priority.
 o get
 public synchronized Object get()
Remove the object that has the highest priority. If several objects are of highest priority then return the one that was put into the queue the longest time ago (Firts-In-First-Out). Blocks when the queue is empty.

Returns:
the next object according to its priority and to the FIFO rule.
 o tryGet
 public synchronized Object tryGet()
Like ``get'' but non-blocking. null is returned when the queue is empty.

Returns:
the next object according to its priority and to the FIFO rule. Returns null if the queue is empty.
 o waitTillEmpty
 public synchronized void waitTillEmpty()
Block until the queue is empty

 o getCapacity
 public int getCapacity()
Returns the capacity of the queue.

Returns:
the capacity of the queue
 o getPriorities
 public int getPriorities()
Returns the number of priorities.

Returns:
the number of priorities
 o isBounded
 public boolean isBounded()
Checks whether the capacity of the queue has an upper bound.

Returns:
whether the capacity of the queue has an upper bound
 o size
 public int size()
Returns the total number of events in the queue.

Returns:
the total number of events in the queue

All Packages  Class Hierarchy  This Package  Previous  Next  Index