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.35 by jsr166, Thu Jul 30 22:45:39 2009 UTC vs.
Revision 1.42 by jsr166, Sat Aug 1 20:48:44 2009 UTC

# Line 294 | Line 294 | public class LinkedTransferQueue<E> exte
294       * @param e the comparison value for checking match
295       * @param mode mode
296       * @param nanos timeout value
297 <     * @return matched item, or s if cancelled
297 >     * @return matched item, or null if cancelled
298       */
299      private E awaitFulfill(Node<E> pred, Node<E> s, E e,
300                             int mode, long nanos) {
# Line 360 | Line 360 | public class LinkedTransferQueue<E> exte
360          for (;;) {
361              Node<E> h = head.get();
362              Node<E> first = h.next;
363 <            if (first != null && first.next == first) { // help advance
363 >            if (first != null && first.get() == first) { // help advance
364                  advanceHead(h, first);
365                  continue;
366              }
# Line 511 | Line 511 | public class LinkedTransferQueue<E> exte
511  
512      /**
513       * Inserts the specified element at the tail of this queue.
514 <     * As the queue is unbounded this method will never throw
514 >     * As the queue is unbounded, this method will never throw
515       * {@link IllegalStateException} or return {@code false}.
516       *
517       * @return {@code true} (as specified by {@link Collection#add})
# Line 522 | Line 522 | public class LinkedTransferQueue<E> exte
522      }
523  
524      /**
525 <     * Transfers the specified element immediately if there exists a
526 <     * consumer already waiting to receive it (in {@link #take} or
527 <     * timed {@link #poll(Object,long,TimeUnit) poll}), otherwise
528 <     * returning {@code false} without enqueuing the element.
525 >     * Transfers the element to a waiting consumer immediately, if possible.
526 >     *
527 >     * <p>More precisely, transfers the specified element immediately
528 >     * if there exists a consumer already waiting to receive it (in
529 >     * {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
530 >     * otherwise returning {@code false} without enqueuing the element.
531       *
532       * @throws NullPointerException if the specified element is null
533       */
# Line 535 | Line 537 | public class LinkedTransferQueue<E> exte
537      }
538  
539      /**
540 <     * Inserts the specified element at the tail of this queue,
541 <     * waiting if necessary for the element to be received by a
542 <     * consumer invoking {@code take} or {@code poll}.
540 >     * Transfers the element to a consumer, waiting if necessary to do so.
541 >     *
542 >     * <p>More precisely, transfers the specified element immediately
543 >     * if there exists a consumer already waiting to receive it (in
544 >     * {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
545 >     * else inserts the specified element at the tail of this queue
546 >     * and waits until the element is received by a consumer.
547       *
542     * @throws InterruptedException {@inheritDoc}
548       * @throws NullPointerException if the specified element is null
549       */
550      public void transfer(E e) throws InterruptedException {
# Line 551 | Line 556 | public class LinkedTransferQueue<E> exte
556      }
557  
558      /**
559 <     * Inserts the specified element at the tail of this queue,
560 <     * waiting up to the specified wait time for the element to be
561 <     * received by a consumer invoking {@code take} or {@code poll}.
559 >     * Transfers the element to a consumer if it is possible to do so
560 >     * before the timeout elapses.
561 >     *
562 >     * <p>More precisely, transfers the specified element immediately
563 >     * if there exists a consumer already waiting to receive it (in
564 >     * {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
565 >     * else inserts the specified element at the tail of this queue
566 >     * and waits until the element is received by a consumer,
567 >     * returning {@code false} if the specified wait time elapses
568 >     * before the element can be transferred.
569       *
558     * @throws InterruptedException {@inheritDoc}
570       * @throws NullPointerException if the specified element is null
571       */
572      public boolean tryTransfer(E e, long timeout, TimeUnit unit)
# Line 576 | Line 587 | public class LinkedTransferQueue<E> exte
587          throw new InterruptedException();
588      }
589  
579    /**
580     * @throws InterruptedException {@inheritDoc}
581     */
590      public E poll(long timeout, TimeUnit unit) throws InterruptedException {
591          E e = xfer(null, TIMEOUT, unit.toNanos(timeout));
592          if (e != null || !Thread.interrupted())
# Line 754 | Line 762 | public class LinkedTransferQueue<E> exte
762          }
763      }
764  
765 +    /**
766 +     * Returns {@code true} if this queue contains no elements.
767 +     *
768 +     * @return {@code true} if this queue contains no elements
769 +     */
770      public boolean isEmpty() {
771          for (;;) {
772              Node<E> h = traversalHead();
# Line 835 | Line 848 | public class LinkedTransferQueue<E> exte
848          }
849      }
850  
851 +    /**
852 +     * Removes a single instance of the specified element from this queue,
853 +     * if it is present.  More formally, removes an element {@code e} such
854 +     * that {@code o.equals(e)}, if this queue contains one or more such
855 +     * elements.
856 +     * Returns {@code true} if this queue contained the specified element
857 +     * (or equivalently, if this queue changed as a result of the call).
858 +     *
859 +     * @param o element to be removed from this queue, if present
860 +     * @return {@code true} if this queue changed as a result of the call
861 +     */
862      public boolean remove(Object o) {
863          if (o == null)
864              return false;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines