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

Comparing jsr166/src/jsr166y/LinkedTransferQueue.java (file contents):
Revision 1.70 by jsr166, Sun Nov 15 02:29:12 2009 UTC vs.
Revision 1.72 by dl, Mon Apr 5 15:50:51 2010 UTC

# Line 879 | Line 879 | public class LinkedTransferQueue<E> exte
879       * Unlinks matched nodes encountered in a traversal from head.
880       */
881      private void sweep() {
882 <        Node p = head, s, n;
883 <        while (p != null && (s = p.next) != null && (n = s.next) != null) {
884 <            if (p == s || s == n)
885 <                p = head; // stale
886 <            else if (s.isMatched())
887 <                p.casNext(s, n);
888 <            else
882 >        for (Node p = head, s, n; p != null && (s = p.next) != null; ) {
883 >            if (p == s)                    // stale
884 >                p = head;
885 >            else if (!s.isMatched())
886                  p = s;
887 +            else if ((n = s.next) == null) // trailing node is pinned
888 +                break;
889 +            else
890 +                p.casNext(s, n);
891          }
892      }
893  
# Line 1124 | Line 1125 | public class LinkedTransferQueue<E> exte
1125       * @return {@code true} if this queue contains no elements
1126       */
1127      public boolean isEmpty() {
1128 <        return firstOfMode(true) == null;
1128 >        for (Node p = head; p != null; p = succ(p)) {
1129 >            if (!p.isMatched())
1130 >                return !p.isData;
1131 >        }
1132 >        return true;
1133      }
1134  
1135      public boolean hasWaitingConsumer() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines