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

Comparing jsr166/src/main/java/util/concurrent/LinkedTransferQueue.java (file contents):
Revision 1.91 by jsr166, Sat Jun 13 17:06:03 2015 UTC vs.
Revision 1.92 by jsr166, Sat Jun 13 18:49:24 2015 UTC

# Line 766 | Line 766 | public class LinkedTransferQueue<E> exte
766      }
767  
768      /**
769     * Returns the item in the first unmatched node with isData; or
770     * null if none.  Used by peek.
771     */
772    private E firstDataItem() {
773        for (Node p = head; p != null; p = succ(p)) {
774            Object item = p.item;
775            if (p.isData) {
776                if (item != null && item != p) {
777                    @SuppressWarnings("unchecked") E itemE = (E) item;
778                    return itemE;
779                }
780            }
781            else if (item == null)
782                return null;
783        }
784        return null;
785    }
786
787    /**
769       * Traverses and counts unmatched nodes of the given mode.
770       * Used by methods size and getWaitingConsumerCount.
771       */
# Line 1419 | Line 1400 | public class LinkedTransferQueue<E> exte
1400      }
1401  
1402      public E peek() {
1403 <        return firstDataItem();
1403 >        restartFromHead: for (;;) {
1404 >            for (Node p = head; p != null;) {
1405 >                Object item = p.item;
1406 >                if (p.isData) {
1407 >                    if (item != null && item != p) {
1408 >                        @SuppressWarnings("unchecked") E e = (E) item;
1409 >                        return e;
1410 >                    }
1411 >                }
1412 >                else if (item == null)
1413 >                    break;
1414 >                if (p == (p = p.next))
1415 >                    continue restartFromHead;
1416 >            }
1417 >            return null;
1418 >        }
1419      }
1420  
1421      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines