Class ConcurrentLinkedBlockingQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- com.linkedin.alpini.base.concurrency.ConcurrentLinkedBlockingQueue<E>
-
- Type Parameters:
E- content type
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.concurrent.BlockingQueue<E>,java.util.Queue<E>
public class ConcurrentLinkedBlockingQueue<E> extends java.util.AbstractQueue<E> implements java.util.concurrent.BlockingQueue<E>A BlockingQueue implementation which uses a collection of concurrent Queues per thread in order to reduce the hotspot of a highly contended mutex or atomic reference.
-
-
Constructor Summary
Constructors Constructor Description ConcurrentLinkedBlockingQueue()Default constructor with a pollSleepMillis of 10 milliseconds.ConcurrentLinkedBlockingQueue(long pollSleepMillis)Constructor which permits specifying the pollSleepMillis
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()intdrainTo(java.util.Collection<? super E> c)intdrainTo(java.util.Collection<? super E> c, int maxElements)booleanisEmpty()java.util.Iterator<E>iterator()protected java.util.Queue<E>newQueue()Create a new single-producer multiple-consumer thread-safe queuebooleanoffer(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()Returns Integer.MAX_VALUE because this is an unbounded queue.booleanremove(java.lang.Object o)booleanremoveIf(java.util.function.Predicate<? super E> filter)intsize()Etake()-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
ConcurrentLinkedBlockingQueue
public ConcurrentLinkedBlockingQueue()
Default constructor with a pollSleepMillis of 10 milliseconds.
-
ConcurrentLinkedBlockingQueue
public ConcurrentLinkedBlockingQueue(@Nonnegative long pollSleepMillis)Constructor which permits specifying the pollSleepMillis- Parameters:
pollSleepMillis- the number of milliseconds that a poller should sleep while waiting.
-
-
Method Detail
-
newQueue
protected java.util.Queue<E> newQueue()
Create a new single-producer multiple-consumer thread-safe queue- Returns:
- new queue instance.
-
iterator
@Nonnull public java.util.Iterator<E> iterator()
-
isEmpty
public boolean isEmpty()
-
size
public int size()
-
clear
public void clear()
-
put
public void put(@Nonnull E e) throws java.lang.InterruptedException- Specified by:
putin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
offer
public boolean offer(E e, long timeout, @Nonnull java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
offerin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
take
@Nonnull public E take() throws java.lang.InterruptedException
- Specified by:
takein interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
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
-
remainingCapacity
public int remainingCapacity()
Returns Integer.MAX_VALUE because this is an unbounded queue.- Specified by:
remainingCapacityin interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
public int drainTo(@Nonnull java.util.Collection<? super E> c)- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
public int drainTo(@Nonnull java.util.Collection<? super E> c, int maxElements)- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<E>
-
offer
public boolean offer(E e)
-
remove
public boolean remove(java.lang.Object o)
-
-