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

Comparing jsr166/src/main/java/util/concurrent/LinkedBlockingQueue.java (file contents):
Revision 1.37 by dl, Sun Oct 31 14:54:19 2004 UTC vs.
Revision 1.38 by dl, Thu Nov 4 19:48:19 2004 UTC

# Line 30 | Line 30 | import java.util.*;
30   *
31   * <p>This class and its iterator implement all of the
32   * <em>optional</em> methods of the {@link Collection} and {@link
33 < * Iterator} interfaces.
33 > * Iterator} interfaces.
34   *
35   * <p>This class is a member of the
36   * <a href="{@docRoot}/../guide/collections/index.html">
# Line 57 | Line 57 | public class LinkedBlockingQueue<E> exte
57       * items have been entered since the signal. And symmetrically for
58       * takes signalling puts. Operations such as remove(Object) and
59       * iterators acquire both locks.
60 <    */
60 >     */
61  
62      /**
63       * Linked list node class
# Line 189 | Line 189 | public class LinkedBlockingQueue<E> exte
189       */
190      public LinkedBlockingQueue(Collection<? extends E> c) {
191          this(Integer.MAX_VALUE);
192 <        for (Iterator<? extends E> it = c.iterator(); it.hasNext();)
193 <            add(it.next());
192 >        for (E e : c)
193 >            add(e);
194      }
195  
196  
# Line 525 | Line 525 | public class LinkedBlockingQueue<E> exte
525          fullyLock();
526          try {
527              head.next = null;
528 <            head.item = null;
529 <            last = head;
528 >            assert head.item == null;
529 >            last = head;
530              if (count.getAndSet(0) == capacity)
531                  notFull.signalAll();
532          } finally {
# Line 544 | Line 544 | public class LinkedBlockingQueue<E> exte
544          try {
545              first = head.next;
546              head.next = null;
547 <            last = head;
547 >            assert head.item == null;
548 >            last = head;
549              if (count.getAndSet(0) == capacity)
550                  notFull.signalAll();
551          } finally {
# Line 557 | Line 558 | public class LinkedBlockingQueue<E> exte
558              p.item = null;
559              ++n;
560          }
560        head.item = null; // Just for GC, so OK if not within lock
561          return n;
562      }
563          
# Line 566 | Line 566 | public class LinkedBlockingQueue<E> exte
566              throw new NullPointerException();
567          if (c == this)
568              throw new IllegalArgumentException();
569        if (maxElements <= 0)
570            return 0;
569          fullyLock();
570          try {
571              int n = 0;
# Line 580 | Line 578 | public class LinkedBlockingQueue<E> exte
578              }
579              if (n != 0) {
580                  head.next = p;
581 <                head.item = null;
582 <                if (p == null)
583 <                    last = head;
581 >                assert head.item == null;
582 >                if (p == null)
583 >                    last = head;
584                  if (count.getAndAdd(-n) == capacity)
585                      notFull.signalAll();
586              }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines