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.43 by jsr166, Sat Aug 1 21:24:01 2009 UTC vs.
Revision 1.44 by jsr166, Tue Aug 4 20:32:16 2009 UTC

# Line 219 | Line 219 | public class LinkedTransferQueue<E> exte
219              Node<E> t = tail.get();
220              Node<E> h = head.get();
221  
222 <            if (t != null && (t == h || t.isData == isData)) {
222 >            if (t == h || t.isData == isData) {
223                  if (s == null)
224                      s = new Node<E>(e, isData);
225                  Node<E> last = t.next;
# Line 231 | Line 231 | public class LinkedTransferQueue<E> exte
231                      tail.compareAndSet(t, s);
232                      return awaitFulfill(t, s, e, mode, nanos);
233                  }
234 <            }
235 <
236 <            else if (h != null) {
234 >            } else {
235                  Node<E> first = h.next;
236                  if (t == tail.get() && first != null &&
237                      advanceHead(h, first)) {
# Line 261 | Line 259 | public class LinkedTransferQueue<E> exte
259              Node<E> t = tail.get();
260              Node<E> h = head.get();
261  
262 <            if (t != null && (t == h || t.isData == isData)) {
262 >            if (t == h || t.isData == isData) {
263                  Node<E> last = t.next;
264                  if (t == tail.get()) {
265                      if (last != null)
# Line 269 | Line 267 | public class LinkedTransferQueue<E> exte
267                      else
268                          return null;
269                  }
270 <            }
273 <            else if (h != null) {
270 >            } else {
271                  Node<E> first = h.next;
272                  if (t == tail.get() &&
273                      first != null &&
# Line 332 | Line 329 | public class LinkedTransferQueue<E> exte
329              }
330              if (spins < 0) {
331                  Node<E> h = head.get(); // only spin if at head
332 <                spins = ((h != null && h.next == s) ?
333 <                         ((mode == TIMEOUT) ?
334 <                          maxTimedSpins : maxUntimedSpins) : 0);
332 >                spins = ((h.next != s) ? 0 :
333 >                         (mode == TIMEOUT) ? maxTimedSpins :
334 >                         maxUntimedSpins);
335              }
336              if (spins > 0)
337                  --spins;
# Line 643 | Line 640 | public class LinkedTransferQueue<E> exte
640          for (;;) {
641              Node<E> t = tail.get();
642              Node<E> h = head.get();
643 <            if (h != null && t != null) {
644 <                Node<E> last = t.next;
645 <                Node<E> first = h.next;
646 <                if (t == tail.get()) {
647 <                    if (last != null)
648 <                        tail.compareAndSet(t, last);
649 <                    else if (first != null) {
650 <                        Object x = first.get();
651 <                        if (x == first)
655 <                            advanceHead(h, first);
656 <                        else
657 <                            return h;
658 <                    }
643 >            Node<E> last = t.next;
644 >            Node<E> first = h.next;
645 >            if (t == tail.get()) {
646 >                if (last != null)
647 >                    tail.compareAndSet(t, last);
648 >                else if (first != null) {
649 >                    Object x = first.get();
650 >                    if (x == first)
651 >                        advanceHead(h, first);
652                      else
653                          return h;
654                  }
655 +                else
656 +                    return h;
657              }
658              reclean();
659          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines