116 |
|
} |
117 |
|
|
118 |
|
/** |
119 |
+ |
* Returns the size of a given queue. A consumer can use |
120 |
+ |
* this to see how big their queue is at any given time. |
121 |
+ |
* they should use their queue number as the parameter. |
122 |
+ |
* |
123 |
+ |
* @param queue The queue number to query. |
124 |
+ |
* @return the current size of the queue. |
125 |
+ |
*/ |
126 |
+ |
public int queueSize(int queue) throws InvalidQueueException { |
127 |
+ |
if (queue >= _lists.size() || _lists.get(queue) == null) { |
128 |
+ |
throw new InvalidQueueException("Requested queue "+queue+" does not exist"); |
129 |
+ |
} |
130 |
+ |
return ((LinkedList) _lists.get(queue)).size(); |
131 |
+ |
} |
132 |
+ |
|
133 |
+ |
/** |
134 |
+ |
* Returns the total numer of elements to have passed |
135 |
+ |
* through this queue (ie. a counter on the add method). |
136 |
+ |
* |
137 |
+ |
* @return the element-ometer |
138 |
+ |
*/ |
139 |
+ |
public int elementCount() { |
140 |
+ |
return _count; |
141 |
+ |
} |
142 |
+ |
|
143 |
+ |
/** |
144 |
|
* This method assigns a queue to a consumer. The idea behind |
145 |
|
* this is to ensure that only 1 consumer can be associated with |
146 |
|
* a given queue, otherwise the whole "blocking" thing fails |