E
- the type of element held in the queuepublic abstract class AbstractLockFreeBlockingDeque<E> extends AbstractDeque<E> implements BlockingDeque<E>
Condition
queues, no intrinsic locks/monitors).
Sub-classes must invoke signalNotEmpty()
when their implementation of
Deque.offerFirst(Object)
/Deque.offerLast(Object)
adds an element to a previously empty
queue. Similarly, they must invoke signalNotFull()
when their implementation of
Deque.pollFirst()
/Deque.pollLast()
removes an element from a previously full queue.
Constructor and Description |
---|
AbstractLockFreeBlockingDeque() |
Modifier and Type | Method and Description |
---|---|
int |
drainTo(Collection<? super E> c) |
int |
drainTo(Collection<? super E> c,
int maxElements) |
protected boolean |
isTentativelyEmpty()
Returns true if this deque is tentatively empty.
|
boolean |
offer(E e,
long timeout,
TimeUnit unit) |
boolean |
offerFirst(E e,
long timeout,
TimeUnit unit) |
protected boolean |
offerFirstInterruptibly(E e)
Adds an element to the head of the deque, allowing interruption.
|
boolean |
offerLast(E e,
long timeout,
TimeUnit unit) |
protected boolean |
offerLastInterruptibly(E e)
Adds an element to the tail of the deque, allowing interruption.
|
E |
poll(long timeout,
TimeUnit unit) |
E |
pollFirst(long timeout,
TimeUnit unit) |
protected E |
pollFirstInterruptibly()
Removes the first element in the deque, allowing interruption.
|
E |
pollLast(long timeout,
TimeUnit unit) |
protected E |
pollLastInterruptibly()
Removes the last element in the deque, allowing interruption.
|
void |
put(E e) |
void |
putFirst(E e) |
void |
putLast(E e) |
protected void |
signalNotEmpty()
Signals a waiting thread that the deque is no longer empty.
|
protected void |
signalNotFull()
Signals a waiting thread that the deque is no longer full.
|
E |
take() |
E |
takeFirst() |
E |
takeLast() |
protected int |
tentativeRemainingCapacity()
Returns the tentative remaining capacity in the deque.
|
add, addFirst, addLast, element, getFirst, getLast, offer, peek, poll, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence
addAll, clear
contains, containsAll, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, addFirst, addLast, contains, element, iterator, offer, offerFirst, offerLast, peek, poll, push, remove, remove, removeFirstOccurrence, removeLastOccurrence, size
remainingCapacity
descendingIterator, getFirst, getLast, peekFirst, peekLast, pollFirst, pollLast, pop, removeFirst, removeLast
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
public void put(E e) throws InterruptedException
put
in interface BlockingDeque<E>
put
in interface BlockingQueue<E>
InterruptedException
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
offer
in interface BlockingDeque<E>
offer
in interface BlockingQueue<E>
InterruptedException
public E take() throws InterruptedException
take
in interface BlockingDeque<E>
take
in interface BlockingQueue<E>
InterruptedException
public E poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface BlockingDeque<E>
poll
in interface BlockingQueue<E>
InterruptedException
protected E pollFirstInterruptibly() throws InterruptedException
Deque.pollFirst()
(and thus not be interruptible),
this method typically need not be overridden. But if any operations are interruptible, this
method should be implemented to propagate that interruption, whereas the Deque.pollFirst()
method (due to its signature) must suppress it.null
if the deque is emptyInterruptedException
- if the operation was interruptedprotected E pollLastInterruptibly() throws InterruptedException
Deque.pollLast()
(and thus not be interruptible),
this method typically need not be overridden. But if any operations are interruptible, this
method should be implemented to propagate that interruption, whereas the Deque.pollLast()
method (due to its signature) must suppress it.null
if the deque is emptyInterruptedException
- if the operation was interruptedprotected boolean offerFirstInterruptibly(E e) throws InterruptedException
Deque.offerFirst(Object)
(and thus not be
interruptible), this method typically need not be overridden. But if any operations are
interruptible, this method should be implemented to propagate that interruption, whereas the
Deque.offerFirst(Object)
method (due to its signature) must suppress it.InterruptedException
- if the operation was interruptedprotected boolean offerLastInterruptibly(E e) throws InterruptedException
Deque.offerLast(Object)
(and thus not be
interruptible), this method typically need not be overridden. But if any operations are
interruptible, this method should be implemented to propagate that interruption, whereas the
Deque.offerLast(Object)
method (due to its signature) must suppress it.InterruptedException
- if the operation was interruptedprotected final void signalNotEmpty()
protected final void signalNotFull()
public void putFirst(E e) throws InterruptedException
putFirst
in interface BlockingDeque<E>
InterruptedException
public void putLast(E e) throws InterruptedException
putLast
in interface BlockingDeque<E>
InterruptedException
public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException
offerFirst
in interface BlockingDeque<E>
InterruptedException
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException
offerLast
in interface BlockingDeque<E>
InterruptedException
public E takeFirst() throws InterruptedException
takeFirst
in interface BlockingDeque<E>
InterruptedException
public E takeLast() throws InterruptedException
takeLast
in interface BlockingDeque<E>
InterruptedException
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException
pollFirst
in interface BlockingDeque<E>
InterruptedException
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException
pollLast
in interface BlockingDeque<E>
InterruptedException
public 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>
protected int tentativeRemainingCapacity()
BlockingQueue.remainingCapacity()
, then this returns a capacity after considering incomplete
operations whereas the other returns "confirmed" remaining capacity, considering only
completed operations.protected boolean isTentativelyEmpty()
AbstractCollection.isEmpty()
, then
this returns true if the deque is empty after considering incomplete operations whereas the
other returns if the deque is "confirmed" empty, considering only completed operations.