|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.LinkedBlockingDeque<E>
com.jolbox.bonecp.LIFOQueue<E>
E - public class LIFOQueue<E>
An implementation that uses LinkedBlockingDeque internally to hide the difference between this version and a BoundedLinkedTransferQueue (when used in FIFO mode). This changes the queue so that every insert function is inserted at the head of the list.
| Constructor Summary | |
|---|---|
LIFOQueue()
|
|
LIFOQueue(int capacity)
|
|
| Method Summary | |
|---|---|
int |
getWaitingConsumerCount()
Returns an estimate of the number of consumers waiting to receive elements via BlockingQueue.take() or timed
poll. |
boolean |
hasWaitingConsumer()
Returns true if there is at least one consumer waiting
to receive an element via BlockingQueue.take() or
timed poll. |
boolean |
offer(E e)
|
void |
transfer(E e)
Transfers the element to a consumer, waiting if necessary to do so. |
boolean |
tryTransfer(E e)
Transfers the element to a waiting consumer immediately, if possible. |
boolean |
tryTransfer(E e,
long timeout,
java.util.concurrent.TimeUnit unit)
Transfers the element to a consumer if it is possible to do so before the timeout elapses. |
| Methods inherited from class java.util.concurrent.LinkedBlockingDeque |
|---|
add, addFirst, addLast, clear, contains, descendingIterator, drainTo, drainTo, element, getFirst, getLast, iterator, offer, offerFirst, offerFirst, offerLast, offerLast, peek, peekFirst, peekLast, poll, poll, pollFirst, pollFirst, pollLast, pollLast, pop, push, put, putFirst, putLast, remainingCapacity, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size, take, takeFirst, takeLast, toArray, toArray, toString |
| Methods inherited from class java.util.AbstractQueue |
|---|
addAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, isEmpty, removeAll, retainAll |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.concurrent.BlockingQueue |
|---|
add, contains, drainTo, drainTo, offer, poll, put, remainingCapacity, remove, take |
| Methods inherited from interface java.util.Queue |
|---|
element, peek, poll, remove |
| Methods inherited from interface java.util.Collection |
|---|
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray |
| Constructor Detail |
|---|
public LIFOQueue(int capacity)
public LIFOQueue()
| Method Detail |
|---|
public boolean tryTransfer(E e)
TransferQueueMore precisely, transfers the specified element immediately
if there exists a consumer already waiting to receive it (in
BlockingQueue.take() or timed poll),
otherwise returning false without enqueuing the element.
tryTransfer in interface TransferQueue<E>e - the element to transfer
true if the element was transferred, else
false
public void transfer(E e)
throws java.lang.InterruptedException
TransferQueueMore precisely, transfers the specified element immediately
if there exists a consumer already waiting to receive it (in
BlockingQueue.take() or timed poll),
else waits until the element is received by a consumer.
transfer in interface TransferQueue<E>e - the element to transfer
java.lang.InterruptedException - if interrupted while waiting,
in which case the element is not left enqueued
public boolean tryTransfer(E e,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
TransferQueueMore precisely, transfers the specified element immediately
if there exists a consumer already waiting to receive it (in
BlockingQueue.take() or timed poll),
else waits until the element is received by a consumer,
returning false if the specified wait time elapses
before the element can be transferred.
tryTransfer in interface TransferQueue<E>e - the element to transfertimeout - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameter
true if successful, or false if
the specified waiting time elapses before completion,
in which case the element is not left enqueued
java.lang.InterruptedException - if interrupted while waiting,
in which case the element is not left enqueuedpublic boolean hasWaitingConsumer()
TransferQueuetrue if there is at least one consumer waiting
to receive an element via BlockingQueue.take() or
timed poll.
The return value represents a momentary state of affairs.
hasWaitingConsumer in interface TransferQueue<E>true if there is at least one waiting consumerpublic int getWaitingConsumerCount()
TransferQueueBlockingQueue.take() or timed
poll. The return value is an
approximation of a momentary state of affairs, that may be
inaccurate if consumers have completed or given up waiting.
The value may be useful for monitoring and heuristics, but
not for synchronization control. Implementations of this
method are likely to be noticeably slower than those for
TransferQueue.hasWaitingConsumer().
getWaitingConsumerCount in interface TransferQueue<E>public boolean offer(E e)
offer in interface java.util.concurrent.BlockingDeque<E>offer in interface java.util.concurrent.BlockingQueue<E>offer in interface java.util.Deque<E>offer in interface java.util.Queue<E>offer in class java.util.concurrent.LinkedBlockingDeque<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||