Class BatchedArrayBlockingQueue<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<T>
org.apache.bookkeeper.common.collections.BatchedArrayBlockingQueue<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,BlockingQueue<T>,Queue<T>,BatchedBlockingQueue<T>
public class BatchedArrayBlockingQueue<T>
extends AbstractQueue<T>
implements BlockingQueue<T>, BatchedBlockingQueue<T>
This implements a
BlockingQueue backed by an array with fixed capacity.
This queue only allows 1 consumer thread to dequeue items and multiple producer threads.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.util.AbstractQueue
add, addAll, element, removeMethods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.BlockingQueue
add, contains, removeMethods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
BatchedArrayBlockingQueue
public BatchedArrayBlockingQueue(int capacity)
-
-
Method Details
-
poll
-
peek
-
offer
-
put
- Specified by:
putin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
putAll
- Throws:
InterruptedException
-
putAll
- Specified by:
putAllin interfaceBatchedBlockingQueue<T>- Throws:
InterruptedException
-
offer
- Specified by:
offerin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
take
- Specified by:
takein interfaceBlockingQueue<T>- Throws:
InterruptedException
-
poll
- Specified by:
pollin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacityin interfaceBlockingQueue<T>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<T>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<T>
-
takeAll
Description copied from interface:BatchedBlockingQueueDrain the queue into an array. Wait if there are no items in the queue.- Specified by:
takeAllin interfaceBatchedBlockingQueue<T>- Returns:
- Throws:
InterruptedException
-
pollAll
Description copied from interface:BatchedBlockingQueueRemoves multiple items from the queue. The method returns when either: 1. At least one item is available 2. The timeout expires- Specified by:
pollAllin interfaceBatchedBlockingQueue<T>- Returns:
- Throws:
InterruptedException
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>- Overrides:
clearin classAbstractQueue<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein classAbstractCollection<T>
-
iterator
- Specified by:
iteratorin interfaceCollection<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin classAbstractCollection<T>
-