Package org.apache.hadoop.hbase.util
Class BoundedPriorityBlockingQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
org.apache.hadoop.hbase.util.BoundedPriorityBlockingQueue<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,BlockingQueue<E>
,Queue<E>
@Private
@Stable
public class BoundedPriorityBlockingQueue<E>
extends AbstractQueue<E>
implements BlockingQueue<E>
A generic bounded blocking Priority-Queue. The elements of the priority queue are ordered
according to the Comparator provided at queue construction time. If multiple elements have the
same priority this queue orders them in FIFO (first-in-first-out) manner. The head of this queue
is the least element with respect to the specified ordering. If multiple elements are tied for
least value, the head is the first one inserted. The queue retrieval operations poll, remove,
peek, and element access the element at the head of the queue.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static class
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ReentrantLock
private final Condition
private final Condition
private final BoundedPriorityBlockingQueue.PriorityQueue<E>
-
Constructor Summary
ConstructorDescriptionBoundedPriorityBlockingQueue
(int capacity, Comparator<? super E> comparator) Creates a PriorityQueue with the specified capacity that orders its elements according to the specified comparator. -
Method Summary
Modifier and TypeMethodDescriptionComparator<? super E>
boolean
int
drainTo
(Collection<? super E> c) int
drainTo
(Collection<? super E> c, int maxElements) iterator()
boolean
boolean
peek()
poll()
void
int
boolean
int
size()
take()
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.concurrent.BlockingQueue
add
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
lock
-
notEmpty
-
notFull
-
queue
-
-
Constructor Details
-
BoundedPriorityBlockingQueue
Creates a PriorityQueue with the specified capacity that orders its elements according to the specified comparator.- Parameters:
capacity
- the capacity of this queuecomparator
- the comparator that will be used to order this priority queue
-
-
Method Details
-
offer
-
put
- Specified by:
put
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
offer
- Specified by:
offer
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
take
- Specified by:
take
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
poll
-
poll
- Specified by:
poll
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
peek
-
size
- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in classAbstractCollection<E>
-
iterator
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in classAbstractCollection<E>
-
comparator
-
remainingCapacity
- Specified by:
remainingCapacity
in interfaceBlockingQueue<E>
-
remove
- Specified by:
remove
in interfaceBlockingQueue<E>
- Specified by:
remove
in interfaceCollection<E>
- Overrides:
remove
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceBlockingQueue<E>
- Specified by:
contains
in interfaceCollection<E>
- Overrides:
contains
in classAbstractCollection<E>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<E>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<E>
-