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.48 by jsr166, Tue Apr 26 01:17:18 2005 UTC vs.
Revision 1.49 by jsr166, Mon May 2 08:35:49 2005 UTC

# Line 387 | Line 387 | public class SynchronousQueue<E> extends
387      /**
388       * Adds the specified element to this queue, waiting if necessary for
389       * another thread to receive it.
390 <     * @param o the element to add
390 >     * @param e the element to add
391       * @throws InterruptedException if interrupted while waiting.
392       * @throws NullPointerException if the specified element is <tt>null</tt>.
393       */
394 <    public void put(E o) throws InterruptedException {
395 <        if (o == null) throw new NullPointerException();
394 >    public void put(E e) throws InterruptedException {
395 >        if (e == null) throw new NullPointerException();
396          final ReentrantLock qlock = this.qlock;
397  
398          for (;;) {
# Line 403 | Line 403 | public class SynchronousQueue<E> extends
403              try {
404                  node = waitingConsumers.deq();
405                  if ( (mustWait = (node == null)) )
406 <                    node = waitingProducers.enq(o);
406 >                    node = waitingProducers.enq(e);
407              } finally {
408                  qlock.unlock();
409              }
# Line 418 | Line 418 | public class SynchronousQueue<E> extends
418                  }
419              }
420  
421 <            else if (node.setItem(o))
421 >            else if (node.setItem(e))
422                  return;
423  
424              // else consumer cancelled, so retry
# Line 428 | Line 428 | public class SynchronousQueue<E> extends
428      /**
429       * Inserts the specified element into this queue, waiting if necessary
430       * up to the specified wait time for another thread to receive it.
431 <     * @param o the element to add
431 >     * @param e the element to add
432       * @param timeout how long to wait before giving up, in units of
433       * <tt>unit</tt>
434       * @param unit a <tt>TimeUnit</tt> determining how to interpret the
# Line 438 | Line 438 | public class SynchronousQueue<E> extends
438       * @throws InterruptedException if interrupted while waiting.
439       * @throws NullPointerException if the specified element is <tt>null</tt>.
440       */
441 <    public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException {
442 <        if (o == null) throw new NullPointerException();
441 >    public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
442 >        if (e == null) throw new NullPointerException();
443          long nanos = unit.toNanos(timeout);
444          final ReentrantLock qlock = this.qlock;
445          for (;;) {
# Line 450 | Line 450 | public class SynchronousQueue<E> extends
450              try {
451                  node = waitingConsumers.deq();
452                  if ( (mustWait = (node == null)) )
453 <                    node = waitingProducers.enq(o);
453 >                    node = waitingProducers.enq(e);
454              } finally {
455                  qlock.unlock();
456              }
# Line 467 | Line 467 | public class SynchronousQueue<E> extends
467                  }
468              }
469  
470 <            else if (node.setItem(o))
470 >            else if (node.setItem(e))
471                  return true;
472  
473              // else consumer cancelled, so retry
# Line 570 | Line 570 | public class SynchronousQueue<E> extends
570      * Inserts the specified element into this queue, if another thread is
571      * waiting to receive it.
572      *
573 <    * @param o the element to add.
573 >    * @param e the element to add.
574      * @return <tt>true</tt> if it was possible to add the element to
575      *         this queue, else <tt>false</tt>
576      * @throws NullPointerException if the specified element is <tt>null</tt>.
577      */
578 <    public boolean offer(E o) {
579 <        if (o == null) throw new NullPointerException();
578 >    public boolean offer(E e) {
579 >        if (e == null) throw new NullPointerException();
580          final ReentrantLock qlock = this.qlock;
581  
582          for (;;) {
# Line 590 | Line 590 | public class SynchronousQueue<E> extends
590              if (node == null)
591                  return false;
592  
593 <            else if (node.setItem(o))
593 >            else if (node.setItem(e))
594                  return true;
595              // else retry
596          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines