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.
-
FIFOQueue(int)
- Create a FIFOQueue with a certain maximum capacity and with one priority
level.
-
FIFOQueue(int, int)
- Create a FIFOQueue with a certain maximum capacity.
-
get()
- Remove the object that has the highest priority.
-
getCapacity()
- Returns the capacity of the queue.
-
getPriorities()
- Returns the number of priorities.
-
isBounded()
- Checks whether the capacity of the queue has an upper bound.
-
put(Object)
- Put an object into the queue.
-
put(Object, int)
- Put an object into the queue for a given priority.
-
size()
- Returns the total number of events in the queue.
-
tryGet()
- Like ``get'' but non-blocking.
-
waitTillEmpty()
- Block until the queue is empty
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.
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.
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
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.
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.
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.
waitTillEmpty
public synchronized void waitTillEmpty()
- Block until the queue is empty
getCapacity
public int getCapacity()
- Returns the capacity of the queue.
- Returns:
- the capacity of the queue
getPriorities
public int getPriorities()
- Returns the number of priorities.
- Returns:
- the number of priorities
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
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