Class SizeBlockingQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
org.elasticsearch.common.util.concurrent.SizeBlockingQueue<E>
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.concurrent.BlockingQueue<E>,java.util.Queue<E>
public class SizeBlockingQueue<E>
extends java.util.AbstractQueue<E>
implements java.util.concurrent.BlockingQueue<E>
A size based queue wrapping another blocking queue to provide (somewhat relaxed) capacity checks.
Mainly makes sense to use with blocking queues that are unbounded to provide the ability to do
capacity verification.
-
Constructor Summary
Constructors Constructor Description SizeBlockingQueue(java.util.concurrent.BlockingQueue<E> queue, int capacity) -
Method Summary
Modifier and Type Method Description intcapacity()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)intdrainTo(java.util.Collection<? super E> c)intdrainTo(java.util.Collection<? super E> c, int maxElements)voidforcePut(E e)Forces adding an element to the queue, without doing size checks.java.util.Iterator<E>iterator()booleanoffer(E e)booleanoffer(E e, long timeout, java.util.concurrent.TimeUnit unit)Epeek()Epoll()Epoll(long timeout, java.util.concurrent.TimeUnit unit)voidput(E e)intremainingCapacity()booleanremove(java.lang.Object o)intsize()Etake()java.lang.Object[]toArray()<T> T[]toArray(T[] a)Methods inherited from class java.util.AbstractQueue
add, addAll, clear, element, removeMethods inherited from class java.util.AbstractCollection
isEmpty, removeAll, retainAll, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.BlockingQueue
addMethods inherited from interface java.util.Collection
addAll, clear, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArrayMethods inherited from interface java.lang.Iterable
forEachMethods inherited from interface java.util.Queue
element, remove
-
Constructor Details
-
SizeBlockingQueue
-
-
Method Details
-
size
public int size() -
capacity
public int capacity() -
iterator
-
peek
- Specified by:
peekin interfacejava.util.Queue<E>
-
poll
- Specified by:
pollin interfacejava.util.Queue<E>
-
poll
public E poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
pollin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
remove
public boolean remove(java.lang.Object o) -
forcePut
Forces adding an element to the queue, without doing size checks.- Throws:
java.lang.InterruptedException
-
offer
-
offer
public boolean offer(E e, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
offerin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
put
- Specified by:
putin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
take
- Specified by:
takein interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacityin interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<E>
-
toArray
public java.lang.Object[] toArray() -
toArray
public <T> T[] toArray(T[] a) -
contains
public boolean contains(java.lang.Object o) -
containsAll
public boolean containsAll(java.util.Collection<?> c)
-