JavaGroups
Class Queue
java.lang.Object
|
+--JavaGroups.Queue
- public class Queue
- extends java.lang.Object
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).
|
Constructor Summary |
Queue()
|
|
Method Summary |
void |
Add(java.lang.Object obj)
|
void |
AddAtHead(java.lang.Object obj)
|
void |
Close(boolean flush_entries)
Marks the queues as closed. |
java.util.Vector |
GetContents()
|
static void |
main(java.lang.String[] args)
|
java.lang.Object |
Peek()
|
java.lang.Object |
Peek(long timeout)
Doesn't remove element |
java.lang.Object |
Remove()
Removes 1 element from head or blocks until next element has been added |
java.lang.Object |
Remove(long timeout)
|
void |
RemoveElement(java.lang.Object obj)
|
void |
Reset()
|
int |
Size()
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Queue
public Queue()
Add
public void Add(java.lang.Object obj)
throws QueueClosed
AddAtHead
public void AddAtHead(java.lang.Object obj)
throws QueueClosed
Remove
public java.lang.Object Remove()
throws QueueClosed
- Removes 1 element from head or blocks until next element has been added
Remove
public java.lang.Object Remove(long timeout)
throws QueueClosed,
Timeout
RemoveElement
public void RemoveElement(java.lang.Object obj)
throws QueueClosed
Peek
public java.lang.Object Peek()
throws QueueClosed
Peek
public java.lang.Object Peek(long timeout)
throws QueueClosed,
Timeout
- Doesn't remove element
Close
public void Close(boolean flush_entries)
- Marks the queues as closed. When an
Add or Remove operation is
attempted on a closed queue, an exception is thrown.
- Parameters:
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.
Reset
public void Reset()
Size
public int Size()
toString
public java.lang.String toString()
- Overrides:
- toString in class java.lang.Object
GetContents
public java.util.Vector GetContents()
main
public static void main(java.lang.String[] args)