E - the type of elements held in this collectionpublic class LinkedTransferQueue<E> extends AbstractQueue<E> implements BlockingQueue<E>
Beware that, unlike in most collections, the size method is NOT a constant-time operation. Because of the asynchronous nature of these queues, determining the current number of elements requires a traversal of the elements.
This class and its iterator implement all of the
optional methods of the Collection and Iterator interfaces.
Memory consistency effects: As with other concurrent
collections, actions in a thread prior to placing an object into a
LinkedTransferQueue
happen-before
actions subsequent to the access or removal of that element from
the LinkedTransferQueue in another thread.
| Modifier and Type | Class and Description |
|---|---|
static class |
LinkedTransferQueue.PaddedAtomicReference<T>
Padded version of AtomicReference used for head, tail and
cleanMe, to alleviate contention across threads CASing one vs
the other.
|
| Constructor and Description |
|---|
LinkedTransferQueue()
Creates an initially empty LinkedTransferQueue.
|
LinkedTransferQueue(Collection<? extends E> c)
Creates a LinkedTransferQueue
initially containing the elements of the given collection,
added in traversal order of the collection's iterator.
|
| Modifier and Type | Method and Description |
|---|---|
int |
drainTo(Collection<? super E> c) |
int |
drainTo(Collection<? super E> c,
int maxElements) |
int |
getWaitingConsumerCount() |
boolean |
hasWaitingConsumer() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
offer(E e) |
boolean |
offer(E e,
long timeout,
TimeUnit unit) |
E |
peek() |
E |
poll() |
E |
poll(long timeout,
TimeUnit unit) |
void |
put(E e) |
int |
remainingCapacity() |
int |
size()
Returns the number of elements in this queue.
|
E |
take() |
void |
transfer(E e) |
boolean |
tryTransfer(E e) |
boolean |
tryTransfer(E e,
long timeout,
TimeUnit unit) |
contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitadd, contains, removeaddAll, clear, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArraypublic LinkedTransferQueue()
public LinkedTransferQueue(Collection<? extends E> c)
c - the collection of elements to initially containNullPointerException - if the specified collection or any
of its elements are nullpublic void put(E e) throws InterruptedException
put in interface BlockingQueue<E>InterruptedExceptionpublic boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
offer in interface BlockingQueue<E>InterruptedExceptionpublic boolean offer(E e)
public void transfer(E e) throws InterruptedException
InterruptedExceptionpublic boolean tryTransfer(E e, long timeout, TimeUnit unit) throws InterruptedException
InterruptedExceptionpublic boolean tryTransfer(E e)
public E take() throws InterruptedException
take in interface BlockingQueue<E>InterruptedExceptionpublic E poll(long timeout, TimeUnit unit) throws InterruptedException
poll in interface BlockingQueue<E>InterruptedExceptionpublic int drainTo(Collection<? super E> c)
drainTo in interface BlockingQueue<E>public int drainTo(Collection<? super E> c, int maxElements)
drainTo in interface BlockingQueue<E>public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in class AbstractCollection<E>public boolean hasWaitingConsumer()
public int size()
Beware that, unlike in most collections, this method is NOT a constant-time operation. Because of the asynchronous nature of these queues, determining the current number of elements requires an O(n) traversal.
size in interface Collection<E>size in class AbstractCollection<E>public int getWaitingConsumerCount()
public int remainingCapacity()
remainingCapacity in interface BlockingQueue<E>Copyright © 2016. All rights reserved.