Class SizeBlockingQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- org.elasticsearch.common.util.concurrent.SizeBlockingQueue<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,BlockingQueue<E>,Queue<E>
public class SizeBlockingQueue<E> extends AbstractQueue<E> implements 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(BlockingQueue<E> queue, int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcapacity()booleancontains(Object o)booleancontainsAll(Collection<?> c)intdrainTo(Collection<? super E> c)intdrainTo(Collection<? super E> c, int maxElements)voidforcePut(E e)Forces adding an element to the queue, without doing size checks.Iterator<E>iterator()booleanoffer(E e)booleanoffer(E e, long timeout, TimeUnit unit)Epeek()Epoll()Epoll(long timeout, TimeUnit unit)voidput(E e)intremainingCapacity()booleanremove(Object o)intsize()Etake()Object[]toArray()<T> T[]toArray(T[] a)-
Methods inherited from class java.util.AbstractCollection
isEmpty, removeAll, retainAll, 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, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray
-
-
-
-
Constructor Detail
-
SizeBlockingQueue
public SizeBlockingQueue(BlockingQueue<E> queue, int capacity)
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein classAbstractCollection<E>
-
capacity
public int capacity()
-
iterator
public Iterator<E> iterator()
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin classAbstractCollection<E>
-
poll
public E poll(long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
pollin interfaceBlockingQueue<E>- Throws:
InterruptedException
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceBlockingQueue<E>- Specified by:
removein interfaceCollection<E>- Overrides:
removein classAbstractCollection<E>
-
forcePut
public void forcePut(E e) throws InterruptedException
Forces adding an element to the queue, without doing size checks.- Throws:
InterruptedException
-
offer
public boolean offer(E e)
-
offer
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
offerin interfaceBlockingQueue<E>- Throws:
InterruptedException
-
put
public void put(E e) throws InterruptedException
- Specified by:
putin interfaceBlockingQueue<E>- Throws:
InterruptedException
-
take
public E take() throws InterruptedException
- Specified by:
takein interfaceBlockingQueue<E>- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacityin interfaceBlockingQueue<E>
-
drainTo
public int drainTo(Collection<? super E> c)
- Specified by:
drainToin interfaceBlockingQueue<E>
-
drainTo
public int drainTo(Collection<? super E> c, int maxElements)
- Specified by:
drainToin interfaceBlockingQueue<E>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<E>- Overrides:
toArrayin classAbstractCollection<E>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArrayin interfaceCollection<E>- Overrides:
toArrayin classAbstractCollection<E>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceBlockingQueue<E>- Specified by:
containsin interfaceCollection<E>- Overrides:
containsin classAbstractCollection<E>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Overrides:
containsAllin classAbstractCollection<E>
-
-