ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java (file contents):
Revision 1.54 by jsr166, Sun May 18 23:47:56 2008 UTC vs.
Revision 1.55 by jsr166, Mon Jul 12 20:15:19 2010 UTC

# Line 69 | Line 69 | public class PriorityBlockingQueue<E> ex
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      /**
# Line 214 | Line 214 | public class PriorityBlockingQueue<E> ex
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();
# Line 234 | Line 228 | public class PriorityBlockingQueue<E> ex
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          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines