97 |
|
// get size before adding to the Queue |
98 |
|
int s = ((LinkedList) _lists.get(i)).size(); |
99 |
|
// check whether we need to remove an item from the current Queue |
100 |
< |
if(_maxSize!=-1 && s==_maxSize && _removeAlgorithm!=DROP) { |
100 |
> |
if(_maxSize!=-1 && s>=_maxSize && _removeAlgorithm!=DROP) { |
101 |
|
// we need to remove an item |
102 |
|
removeQueueItem((LinkedList) _lists.get(i)); |
103 |
|
} |
104 |
|
// check if we should add (not if Queue full, and using DROP algorithm) |
105 |
< |
if(!(s==_maxSize && _removeAlgorithm==DROP)) { |
105 |
> |
if(!(s>=_maxSize && _removeAlgorithm==DROP)) { |
106 |
|
// add the next item, ensuring we lock |
107 |
|
synchronized(this) { |
108 |
|
// LinkedList.add() does the same thing, but this ensures behaviour |
111 |
|
} |
112 |
|
// if the queue was empty before the add it is possible |
113 |
|
// that a consumer is waiting... so we notify them |
114 |
< |
if (s == 0) { |
115 |
< |
synchronized(((LinkedList) _lists.get(i))) { |
116 |
< |
((LinkedList) _lists.get(i)).notifyAll(); |
117 |
< |
} |
114 |
> |
synchronized(((LinkedList) _lists.get(i))) { |
115 |
> |
((LinkedList) _lists.get(i)).notifyAll(); |
116 |
|
} |
117 |
|
} |
118 |
|
} |