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

Comparing jsr166/src/main/java/util/concurrent/SynchronousQueue.java (file contents):
Revision 1.82 by jsr166, Fri Dec 2 14:02:42 2011 UTC vs.
Revision 1.83 by jsr166, Fri Dec 2 15:47:22 2011 UTC

# Line 292 | Line 292 | public class SynchronousQueue<E> extends
292          /**
293           * Puts or takes an item.
294           */
295 +        @SuppressWarnings("unchecked")
296          E transfer(E e, boolean timed, long nanos) {
297              /*
298               * Basic algorithm is to loop trying one of three actions:
# Line 333 | Line 334 | public class SynchronousQueue<E> extends
334                          }
335                          if ((h = head) != null && h.next == s)
336                              casHead(h, s.next);     // help s's fulfiller
337 <                        @SuppressWarnings("unchecked")
337 <                        E x = (E) ((mode == REQUEST) ? m.item : s.item);
338 <                        return x;
337 >                        return (E) ((mode == REQUEST) ? m.item : s.item);
338                      }
339                  } else if (!isFulfilling(h.mode)) { // try to fulfill
340                      if (h.isCancelled())            // already cancelled
# Line 351 | Line 350 | public class SynchronousQueue<E> extends
350                              SNode mn = m.next;
351                              if (m.tryMatch(s)) {
352                                  casHead(s, mn);     // pop both s and m
353 <                                @SuppressWarnings("unchecked")
355 <                                E x = (E) ((mode == REQUEST) ? m.item : s.item);
356 <                                return x;
353 >                                return (E) ((mode == REQUEST) ? m.item : s.item);
354                              } else                  // lost match
355                                  s.casNext(m, mn);   // help unlink
356                          }
# Line 613 | Line 610 | public class SynchronousQueue<E> extends
610          /**
611           * Puts or takes an item.
612           */
613 +        @SuppressWarnings("unchecked")
614          E transfer(E e, boolean timed, long nanos) {
615              /* Basic algorithm is to loop trying to take either of
616               * two actions:
# Line 676 | Line 674 | public class SynchronousQueue<E> extends
674                              s.item = s;
675                          s.waiter = null;
676                      }
677 +                    return (x != null) ? (E)x : e;
678  
680                    if (x == null)
681                        return e;
682                    else {
683                        @SuppressWarnings("unchecked") E ret = (E)x;
684                        return ret;
685                    }
679                  } else {                            // complementary-mode
680                      QNode m = h.next;               // node to fulfill
681                      if (t != tail || m == null || h != head)
# Line 698 | Line 691 | public class SynchronousQueue<E> extends
691  
692                      advanceHead(h, m);              // successfully fulfilled
693                      LockSupport.unpark(m.waiter);
694 <
702 <                    if (x == null)
703 <                        return e;
704 <                    else {
705 <                        @SuppressWarnings("unchecked") E ret = (E)x;
706 <                        return ret;
707 <                    }
694 >                    return (x != null) ? (E)x : e;
695                  }
696              }
697          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines