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.75 by jsr166, Tue Jun 21 19:47:21 2011 UTC vs.
Revision 1.76 by jsr166, Mon Jun 27 21:01:06 2011 UTC

# Line 722 | Line 722 | public class PriorityBlockingQueue<E> ex
722       * @throws IllegalArgumentException      {@inheritDoc}
723       */
724      public int drainTo(Collection<? super E> c) {
725 <        if (c == null)
726 <            throw new NullPointerException();
727 <        if (c == this)
728 <            throw new IllegalArgumentException();
729 <        final ReentrantLock lock = this.lock;
730 <        lock.lock();
731 <        try {
732 <            int n = 0;
733 <            for (E e; (e = extract()) != null;) {
734 <                c.add(e);
735 <                ++n;
736 <            }
737 <            return n;
738 <        } finally {
739 <            lock.unlock();
740 <        }
725 >        return drainTo(c, Integer.MAX_VALUE);
726      }
727  
728      /**
# Line 756 | Line 741 | public class PriorityBlockingQueue<E> ex
741          final ReentrantLock lock = this.lock;
742          lock.lock();
743          try {
744 <            int n = 0;
745 <            for (E e; n < maxElements && (e = extract()) != null;) {
746 <                c.add(e);
747 <                ++n;
744 >            int n = Math.min(size, maxElements);
745 >            for (int i = 0; i < n; i++) {
746 >                c.add((E) queue[0]); // In this order, in case add() throws.
747 >                extract();
748              }
749              return n;
750          } finally {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines