62 |
|
* This method returns an object from the front of a given queue. |
63 |
|
* It will block until data exists in the queue if required. |
64 |
|
* |
65 |
+ |
* @param The queue to retrieve data from. |
66 |
|
* @return The object from the front of the queue. |
67 |
|
* @throws InvalidQueueException if the queue does not exist. |
68 |
|
*/ |
96 |
|
* shutdown() type methods that may have problems closing |
97 |
|
* if the thread of control is waiting on a queue. |
98 |
|
* |
99 |
< |
* @param queue the queue to release |
99 |
> |
* @param queue the queue to release. |
100 |
|
*/ |
101 |
|
public void releaseQueue(int queue) { |
102 |
|
synchronized(((LinkedList) _lists.get(queue))) { |
103 |
|
((LinkedList) _lists.get(queue)).notifyAll(); |
104 |
|
} |
105 |
|
} |
106 |
+ |
|
107 |
+ |
/** |
108 |
+ |
* This method erases the contents of a given queue. This |
109 |
+ |
* method should be used with care. It can only empty one |
110 |
+ |
* internal queue, not all of them. This must be called |
111 |
+ |
* multiple times to empty all queues. |
112 |
+ |
* |
113 |
+ |
* @param queue the queue to empty. |
114 |
+ |
*/ |
115 |
+ |
public void clearQueue(int queue) { |
116 |
+ |
synchronized(this) { |
117 |
+ |
((LinkedList) _lists.get(queue)).clear(); |
118 |
+ |
} |
119 |
+ |
} |
120 |
|
|
121 |
|
/** |
122 |
|
* This method returns a textual status of the queues. It |
151 |
|
* |
152 |
|
* @param queue The queue number to query. |
153 |
|
* @return the current size of the queue. |
154 |
+ |
* @throws InvalidQueueException if the queue does not exist. |
155 |
|
*/ |
156 |
|
public int queueSize(int queue) throws InvalidQueueException { |
157 |
|
if (queue >= _lists.size() || _lists.get(queue) == null) { |
164 |
|
* Returns the total numer of elements to have passed |
165 |
|
* through this queue (ie. a counter on the add method). |
166 |
|
* |
167 |
< |
* @return the element-ometer |
167 |
> |
* @return the element-ometer. |
168 |
|
*/ |
169 |
|
public int elementCount() { |
170 |
|
return _count; |
216 |
|
* This uses the uk.ac.ukc.iscream.util.FormatName class |
217 |
|
* to format the toString() |
218 |
|
* |
219 |
< |
* @return the name of this class and its CVS revision |
219 |
> |
* @return the name of this class and its CVS revision. |
220 |
|
*/ |
221 |
|
public String toString() { |
222 |
|
return FormatName.getName( |