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.53 by jsr166, Mon Aug 31 21:48:14 2009 UTC vs.
Revision 1.54 by dl, Tue Sep 28 11:05:19 2010 UTC

# Line 160 | Line 160 | public class LinkedBlockingQueue<E> exte
160      }
161  
162      /**
163 <     * Creates a node and links it at end of queue.
163 >     * Links node at end of queue.
164       *
165 <     * @param x the item
165 >     * @param node the node
166       */
167 <    private void enqueue(E x) {
167 >    private void enqueue(Node<E> node) {
168          // assert putLock.isHeldByCurrentThread();
169          // assert last.next == null;
170 <        last = last.next = new Node<E>(x);
170 >        last = last.next = node;
171      }
172  
173      /**
# Line 253 | Line 253 | public class LinkedBlockingQueue<E> exte
253                      throw new NullPointerException();
254                  if (n == capacity)
255                      throw new IllegalStateException("Queue full");
256 <                enqueue(e);
256 >                enqueue(new Node<E>(e));
257                  ++n;
258              }
259              count.set(n);
# Line 303 | Line 303 | public class LinkedBlockingQueue<E> exte
303          // Note: convention in all put/take/etc is to preset local var
304          // holding count negative to indicate failure unless set.
305          int c = -1;
306 +        Node<E> node = new Node(e);
307          final ReentrantLock putLock = this.putLock;
308          final AtomicInteger count = this.count;
309          putLock.lockInterruptibly();
# Line 318 | Line 319 | public class LinkedBlockingQueue<E> exte
319              while (count.get() == capacity) {
320                  notFull.await();
321              }
322 <            enqueue(e);
322 >            enqueue(node);
323              c = count.getAndIncrement();
324              if (c + 1 < capacity)
325                  notFull.signal();
# Line 353 | Line 354 | public class LinkedBlockingQueue<E> exte
354                      return false;
355                  nanos = notFull.awaitNanos(nanos);
356              }
357 <            enqueue(e);
357 >            enqueue(new Node<E>(e));
358              c = count.getAndIncrement();
359              if (c + 1 < capacity)
360                  notFull.signal();
# Line 382 | Line 383 | public class LinkedBlockingQueue<E> exte
383          if (count.get() == capacity)
384              return false;
385          int c = -1;
386 +        Node<E> node = new Node(e);
387          final ReentrantLock putLock = this.putLock;
388          putLock.lock();
389          try {
390              if (count.get() < capacity) {
391 <                enqueue(e);
391 >                enqueue(node);
392                  c = count.getAndIncrement();
393                  if (c + 1 < capacity)
394                      notFull.signal();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines