exte
}
/**
- * Transfers the specified element immediately if there exists a
- * consumer already waiting to receive it (in {@link #take} or
- * timed {@link #poll(Object,long,TimeUnit) poll}), otherwise
- * returning {@code false} without enqueuing the element.
+ * Transfers the element to a waiting consumer immediately, if possible.
+ *
+ * More precisely, transfers the specified element immediately
+ * if there exists a consumer already waiting to receive it (in
+ * {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
+ * otherwise returning {@code false} without enqueuing the element.
*
* @throws NullPointerException if the specified element is null
*/
@@ -535,11 +537,14 @@ public class LinkedTransferQueue exte
}
/**
- * Inserts the specified element at the tail of this queue,
- * waiting if necessary for the element to be received by a
- * consumer invoking {@code take} or {@code poll}.
+ * Transfers the element to a consumer, waiting if necessary to do so.
+ *
+ * More precisely, transfers the specified element immediately
+ * if there exists a consumer already waiting to receive it (in
+ * {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
+ * else inserts the specified element at the tail of this queue
+ * and waits until the element is received by a consumer.
*
- * @throws InterruptedException {@inheritDoc}
* @throws NullPointerException if the specified element is null
*/
public void transfer(E e) throws InterruptedException {
@@ -551,11 +556,17 @@ public class LinkedTransferQueue exte
}
/**
- * Inserts the specified element at the tail of this queue,
- * waiting up to the specified wait time for the element to be
- * received by a consumer invoking {@code take} or {@code poll}.
+ * Transfers the element to a consumer if it is possible to do so
+ * before the timeout elapses.
+ *
+ * More precisely, transfers the specified element immediately
+ * if there exists a consumer already waiting to receive it (in
+ * {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
+ * else inserts the specified element at the tail of this queue
+ * and waits until the element is received by a consumer,
+ * returning {@code false} if the specified wait time elapses
+ * before the element can be transferred.
*
- * @throws InterruptedException {@inheritDoc}
* @throws NullPointerException if the specified element is null
*/
public boolean tryTransfer(E e, long timeout, TimeUnit unit)
@@ -576,9 +587,6 @@ public class LinkedTransferQueue exte
throw new InterruptedException();
}
- /**
- * @throws InterruptedException {@inheritDoc}
- */
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
E e = xfer(null, TIMEOUT, unit.toNanos(timeout));
if (e != null || !Thread.interrupted())
@@ -754,6 +762,11 @@ public class LinkedTransferQueue exte
}
}
+ /**
+ * Returns {@code true} if this queue contains no elements.
+ *
+ * @return {@code true} if this queue contains no elements
+ */
public boolean isEmpty() {
for (;;) {
Node h = traversalHead();
@@ -835,6 +848,17 @@ public class LinkedTransferQueue exte
}
}
+ /**
+ * Removes a single instance of the specified element from this queue,
+ * if it is present. More formally, removes an element {@code e} such
+ * that {@code o.equals(e)}, if this queue contains one or more such
+ * elements.
+ * Returns {@code true} if this queue contained the specified element
+ * (or equivalently, if this queue changed as a result of the call).
+ *
+ * @param o element to be removed from this queue, if present
+ * @return {@code true} if this queue changed as a result of the call
+ */
public boolean remove(Object o) {
if (o == null)
return false;