69 |
|
implements BlockingQueue<E>, java.io.Serializable { |
70 |
|
private static final long serialVersionUID = 5595510919245408276L; |
71 |
|
|
72 |
< |
private final PriorityQueue<E> q; |
73 |
< |
private final ReentrantLock lock = new ReentrantLock(true); |
72 |
> |
final PriorityQueue<E> q; |
73 |
> |
final ReentrantLock lock = new ReentrantLock(true); |
74 |
|
private final Condition notEmpty = lock.newCondition(); |
75 |
|
|
76 |
|
/** |
214 |
|
final ReentrantLock lock = this.lock; |
215 |
|
lock.lockInterruptibly(); |
216 |
|
try { |
217 |
< |
try { |
218 |
< |
while (q.size() == 0) |
219 |
< |
notEmpty.await(); |
220 |
< |
} catch (InterruptedException ie) { |
221 |
< |
notEmpty.signal(); // propagate to non-interrupted thread |
222 |
< |
throw ie; |
223 |
< |
} |
224 |
< |
E x = q.poll(); |
225 |
< |
assert x != null; |
217 |
> |
E x; |
218 |
> |
while ( (x = q.poll()) == null) |
219 |
> |
notEmpty.await(); |
220 |
|
return x; |
221 |
|
} finally { |
222 |
|
lock.unlock(); |
228 |
|
final ReentrantLock lock = this.lock; |
229 |
|
lock.lockInterruptibly(); |
230 |
|
try { |
231 |
< |
for (;;) { |
232 |
< |
E x = q.poll(); |
239 |
< |
if (x != null) |
240 |
< |
return x; |
231 |
> |
E x; |
232 |
> |
while ( (x = q.poll()) == null) { |
233 |
|
if (nanos <= 0) |
234 |
|
return null; |
235 |
< |
try { |
244 |
< |
nanos = notEmpty.awaitNanos(nanos); |
245 |
< |
} catch (InterruptedException ie) { |
246 |
< |
notEmpty.signal(); // propagate to non-interrupted thread |
247 |
< |
throw ie; |
248 |
< |
} |
235 |
> |
nanos = notEmpty.awaitNanos(nanos); |
236 |
|
} |
237 |
+ |
return x; |
238 |
|
} finally { |
239 |
|
lock.unlock(); |
240 |
|
} |