143 |
|
*/ |
144 |
|
public boolean offer(E o) { |
145 |
|
if (o == null) throw new NullPointerException(); |
146 |
+ |
final ReentrantLock lock = this.lock; |
147 |
|
lock.lock(); |
148 |
|
try { |
149 |
|
boolean ok = q.offer(o); |
185 |
|
} |
186 |
|
|
187 |
|
public E take() throws InterruptedException { |
188 |
+ |
final ReentrantLock lock = this.lock; |
189 |
|
lock.lockInterruptibly(); |
190 |
|
try { |
191 |
|
try { |
205 |
|
|
206 |
|
|
207 |
|
public E poll() { |
208 |
+ |
final ReentrantLock lock = this.lock; |
209 |
|
lock.lock(); |
210 |
|
try { |
211 |
|
return q.poll(); |
216 |
|
|
217 |
|
public E poll(long timeout, TimeUnit unit) throws InterruptedException { |
218 |
|
long nanos = unit.toNanos(timeout); |
219 |
+ |
final ReentrantLock lock = this.lock; |
220 |
|
lock.lockInterruptibly(); |
221 |
|
try { |
222 |
|
for (;;) { |
238 |
|
} |
239 |
|
|
240 |
|
public E peek() { |
241 |
+ |
final ReentrantLock lock = this.lock; |
242 |
|
lock.lock(); |
243 |
|
try { |
244 |
|
return q.peek(); |
248 |
|
} |
249 |
|
|
250 |
|
public int size() { |
251 |
+ |
final ReentrantLock lock = this.lock; |
252 |
|
lock.lock(); |
253 |
|
try { |
254 |
|
return q.size(); |
267 |
|
} |
268 |
|
|
269 |
|
public boolean remove(Object o) { |
270 |
+ |
final ReentrantLock lock = this.lock; |
271 |
|
lock.lock(); |
272 |
|
try { |
273 |
|
return q.remove(o); |
277 |
|
} |
278 |
|
|
279 |
|
public boolean contains(Object o) { |
280 |
+ |
final ReentrantLock lock = this.lock; |
281 |
|
lock.lock(); |
282 |
|
try { |
283 |
|
return q.contains(o); |
287 |
|
} |
288 |
|
|
289 |
|
public Object[] toArray() { |
290 |
+ |
final ReentrantLock lock = this.lock; |
291 |
|
lock.lock(); |
292 |
|
try { |
293 |
|
return q.toArray(); |
298 |
|
|
299 |
|
|
300 |
|
public String toString() { |
301 |
+ |
final ReentrantLock lock = this.lock; |
302 |
|
lock.lock(); |
303 |
|
try { |
304 |
|
return q.toString(); |
312 |
|
throw new NullPointerException(); |
313 |
|
if (c == this) |
314 |
|
throw new IllegalArgumentException(); |
315 |
+ |
final ReentrantLock lock = this.lock; |
316 |
|
lock.lock(); |
317 |
|
try { |
318 |
|
int n = 0; |
334 |
|
throw new IllegalArgumentException(); |
335 |
|
if (maxElements <= 0) |
336 |
|
return 0; |
337 |
+ |
final ReentrantLock lock = this.lock; |
338 |
|
lock.lock(); |
339 |
|
try { |
340 |
|
int n = 0; |
354 |
|
* The queue will be empty after this call returns. |
355 |
|
*/ |
356 |
|
public void clear() { |
357 |
+ |
final ReentrantLock lock = this.lock; |
358 |
|
lock.lock(); |
359 |
|
try { |
360 |
|
q.clear(); |
364 |
|
} |
365 |
|
|
366 |
|
public <T> T[] toArray(T[] a) { |
367 |
+ |
final ReentrantLock lock = this.lock; |
368 |
|
lock.lock(); |
369 |
|
try { |
370 |
|
return q.toArray(a); |
384 |
|
* @return an iterator over the elements in this queue. |
385 |
|
*/ |
386 |
|
public Iterator<E> iterator() { |
387 |
+ |
final ReentrantLock lock = this.lock; |
388 |
|
lock.lock(); |
389 |
|
try { |
390 |
|
return new Itr(q.iterator()); |
410 |
|
} |
411 |
|
|
412 |
|
public E next() { |
413 |
+ |
ReentrantLock lock = PriorityBlockingQueue.this.lock; |
414 |
|
lock.lock(); |
415 |
|
try { |
416 |
|
return iter.next(); |
420 |
|
} |
421 |
|
|
422 |
|
public void remove() { |
423 |
+ |
ReentrantLock lock = PriorityBlockingQueue.this.lock; |
424 |
|
lock.lock(); |
425 |
|
try { |
426 |
|
iter.remove(); |