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

Comparing jsr166/src/main/java/util/concurrent/LinkedBlockingDeque.java (file contents):
Revision 1.24 by jsr166, Thu Sep 30 00:50:19 2010 UTC vs.
Revision 1.25 by jsr166, Wed Nov 3 19:33:54 2010 UTC

# Line 1042 | Line 1042 | public class LinkedBlockingDeque<E>
1042          }
1043  
1044          /**
1045 +         * Returns the successor node of the given non-null, but
1046 +         * possibly previously deleted, node.
1047 +         */
1048 +        private Node<E> succ(Node<E> n) {
1049 +            // Chains of deleted nodes ending in null or self-links
1050 +            // are possible if multiple interior nodes are removed.
1051 +            for (;;) {
1052 +                Node<E> s = nextNode(n);
1053 +                if (s == null)
1054 +                    return null;
1055 +                else if (s.item != null)
1056 +                    return s;
1057 +                else if (s == n)
1058 +                    return firstNode();
1059 +                else
1060 +                    n = s;
1061 +            }
1062 +        }
1063 +
1064 +        /**
1065           * Advances next.
1066           */
1067          void advance() {
# Line 1049 | Line 1069 | public class LinkedBlockingDeque<E>
1069              lock.lock();
1070              try {
1071                  // assert next != null;
1072 <                Node<E> s = nextNode(next);
1053 <                if (s == next) {
1054 <                    next = firstNode();
1055 <                } else {
1056 <                    // Skip over removed nodes.
1057 <                    // May be necessary if multiple interior Nodes are removed.
1058 <                    while (s != null && s.item == null)
1059 <                        s = nextNode(s);
1060 <                    next = s;
1061 <                }
1072 >                next = succ(next);
1073                  nextItem = (next == null) ? null : next.item;
1074              } finally {
1075                  lock.unlock();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines