|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.dyade.aaa.common.Queue
public class Queue
The Queue
class implements a First-In-First-Out
(FIFO) list of objects.
A queue is for the exclusive use of one single consumer, whereas many
producers may access it. It is ready for use after instantiation. A
producer may wait for the queue to be empty by calling the
stop()
method. This method returns when the queue is
actually empty, and prohibits any further call to the push
method. To be able to use the queue again, it must be re-started through
the start()
method.
Field Summary | |
---|---|
private boolean |
closed
true if the queue has been closed. |
private java.util.List |
elements
The list holding queue elements. |
private static long |
serialVersionUID
define serialVersionUID for interoperability |
private boolean |
stopping
true if a producer called the stop()
method. |
Constructor Summary | |
---|---|
Queue()
Constructs a Queue instance. |
Method Summary | |
---|---|
void |
clear()
Removes all of the elements from this queue. |
void |
close()
Closes the queue. |
java.lang.Object |
get()
Waits for an object to be pushed in the queue, and eventually returns it without removing it. |
java.lang.Object |
getAndPop()
Waits for an object to be pushed in the queue, then removes and returns the object at the top of this queue. |
boolean |
isEmpty()
Returns true if this queue contains no elements. |
java.lang.Object |
pop()
Removes and returns the object at the top of this queue. |
void |
push(java.lang.Object item)
Pushes an item at the end of this queue. |
int |
size()
Returns the number of elements in this list. |
void |
start()
Authorizes the use of the queue by producers. |
void |
stop()
Stops the queue by returning when it is empty and prohibiting any further producers call to the push method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private java.util.List elements
private boolean stopping
true
if a producer called the stop()
method.
private boolean closed
true
if the queue has been closed.
Constructor Detail |
---|
public Queue()
Queue
instance.
Method Detail |
---|
public void push(java.lang.Object item)
item
- The item to be pushed at the end of this queue.
StoppedQueueException
- If the queue is stopping or stopped.public java.lang.Object get() throws java.lang.InterruptedException
java.lang.InterruptedException
public java.lang.Object pop()
EmptyQueueException
- If the queue is empty.public java.lang.Object getAndPop() throws java.lang.InterruptedException
java.lang.InterruptedException
public void start()
public void stop() throws java.lang.InterruptedException
push
method.
java.lang.InterruptedException
public void close()
get()
with an
InterruptedException
.
public boolean isEmpty()
public void clear()
public int size()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |