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.68 by jsr166, Sun Nov 15 01:53:11 2009 UTC vs.
Revision 1.72 by dl, Mon Apr 5 15:50:51 2010 UTC

# Line 343 | Line 343 | public class LinkedTransferQueue<E> exte
343       * When these cases arise, rather than always retraversing the
344       * entire list to find an actual predecessor to unlink (which
345       * won't help for case (1) anyway), we record a conservative
346 <     * estimate of possible unsplice failures (in "sweepVotes).  We
346 >     * estimate of possible unsplice failures (in "sweepVotes").  We
347       * trigger a full sweep when the estimate exceeds a threshold
348       * indicating the maximum number of estimated removal failures to
349       * tolerate before sweeping through, unlinking cancelled nodes
# Line 876 | Line 876 | public class LinkedTransferQueue<E> exte
876      }
877  
878      /**
879 <     * Unlink matched nodes encountered in a traversal from head
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