|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jgroups.util.Queue
public class Queue
Elements are added at the tail and removed from the head. Class is thread-safe in that 1 producer and 1 consumer may add/remove elements concurrently. The class is not explicitely designed for multiple producers or consumers. Implemented as a linked list, so that removal of an element at the head does not cause a right-shift of the remaining elements (as in a Vector-based implementation).
Field Summary | |
---|---|
protected static Log |
log
|
Constructor Summary | |
---|---|
Queue()
creates an empty queue |
Method Summary | |
---|---|
void |
add(java.lang.Object obj)
adds an object to the tail of this queue If the queue has been closed with close(true) no exception will be thrown if the queue has not been flushed yet. |
void |
addAll(java.util.Collection c)
|
void |
addAll(java.util.List<java.lang.Object> list)
|
void |
clear()
Removes all elements from the queue. |
void |
close(boolean flush_entries)
Marks the queues as closed. |
boolean |
closed()
returns true if the Queue has been closed however, this method will return false if the queue has been closed using the close(true) method and the last element has yet not been received. |
java.lang.Object |
getFirst()
Returns the first element. |
java.lang.Object |
getLast()
Returns the last element. |
java.lang.Object |
peek()
returns the first object on the queue, without removing it. |
java.lang.Object |
peek(long timeout)
returns the first object on the queue, without removing it. |
java.lang.Object |
remove()
Removes 1 element from head or blocks until next element has been added or until queue has been closed |
java.lang.Object |
remove(long timeout)
Removes 1 element from the head. |
void |
removeElement(java.lang.Object obj)
removes a specific object from the queue. |
java.lang.Object |
removeWait(long timeout)
|
void |
reset()
resets the queue. |
int |
size()
returns the number of objects that are currently in the queue |
java.lang.String |
toString()
prints the size of the queue |
java.util.LinkedList |
values()
Returns all the elements of the queue |
void |
waitUntilClosed(long timeout)
Waits until the queue has been closed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final Log log
Constructor Detail |
---|
public Queue()
Method Detail |
---|
public java.lang.Object getFirst()
public java.lang.Object getLast()
public boolean closed()
public void add(java.lang.Object obj) throws QueueClosedException
obj
- - the object to be added to the queue
QueueClosedException
- exception if closed() returns truepublic void addAll(java.util.Collection c) throws QueueClosedException
QueueClosedException
public void addAll(java.util.List<java.lang.Object> list) throws QueueClosedException
QueueClosedException
public java.lang.Object remove() throws QueueClosedException
QueueClosedException
public java.lang.Object remove(long timeout) throws QueueClosedException, TimeoutException
timeout
- - the number of milli seconds this operation will wait before it times out
QueueClosedException
TimeoutException
public java.lang.Object removeWait(long timeout) throws QueueClosedException, TimeoutException
QueueClosedException
TimeoutException
public void removeElement(java.lang.Object obj) throws QueueClosedException
obj
- the actual object to be removed from the queue
QueueClosedException
public java.lang.Object peek() throws QueueClosedException
QueueClosedException
public java.lang.Object peek(long timeout) throws QueueClosedException, TimeoutException
timeout
- how long in milli seconds will this operation wait for an object to be added to the queue
before it times out
QueueClosedException
TimeoutException
public void clear()
public void close(boolean flush_entries)
add
or remove
operation is
attempted on a closed queue, an exception is thrown.
flush_entries
- When true, a end-of-entries marker is added to the end of the queue.
Entries may be added and removed, but when the end-of-entries marker
is encountered, the queue is marked as closed. This allows to flush
pending messages before closing the queue.public void waitUntilClosed(long timeout)
timeout
- Number of milliseconds to wait. A value <= 0 means to wait foreverpublic void reset()
public java.util.LinkedList values()
public int size()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |