Package alluxio.util.executor
Class UniqueBlockingQueue<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<T>
-
- alluxio.util.executor.UniqueBlockingQueue<T>
-
- Type Parameters:
T
- element type
- All Implemented Interfaces:
java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.concurrent.BlockingQueue<T>
,java.util.Queue<T>
public class UniqueBlockingQueue<T> extends java.util.AbstractQueue<T> implements java.util.concurrent.BlockingQueue<T>
A blocking queue containing only unique elements, based on LinkedBlockingQueue implementation. We serialize the insertion into the queue, otherwise, we may end up with duplicate elements in the queue.
-
-
Constructor Summary
Constructors Constructor Description UniqueBlockingQueue(int capacity)
Constructor for a UniqueBlockingQueue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
drainTo(java.util.Collection<? super T> c)
int
drainTo(java.util.Collection<? super T> c, int maxElements)
java.util.Iterator<T>
iterator()
boolean
offer(T e)
boolean
offer(T e, long timeout, java.util.concurrent.TimeUnit unit)
T
peek()
T
poll()
T
poll(long timeout, java.util.concurrent.TimeUnit unit)
void
put(T e)
int
remainingCapacity()
int
size()
T
take()
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
put
public void put(T e) throws java.lang.InterruptedException
- Specified by:
put
in interfacejava.util.concurrent.BlockingQueue<T>
- Throws:
java.lang.InterruptedException
-
offer
public boolean offer(T e)
-
offer
public boolean offer(T e, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
offer
in interfacejava.util.concurrent.BlockingQueue<T>
- Throws:
java.lang.InterruptedException
-
take
public T take() throws java.lang.InterruptedException
- Specified by:
take
in interfacejava.util.concurrent.BlockingQueue<T>
- Throws:
java.lang.InterruptedException
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacity
in interfacejava.util.concurrent.BlockingQueue<T>
-
drainTo
public int drainTo(java.util.Collection<? super T> c)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<T>
-
drainTo
public int drainTo(java.util.Collection<? super T> c, int maxElements)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<T>
-
iterator
public java.util.Iterator<T> iterator()
-
size
public int size()
-
poll
public T poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
poll
in interfacejava.util.concurrent.BlockingQueue<T>
- Throws:
java.lang.InterruptedException
-
-