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 void
clear()
int
drainTo(java.util.Collection<? super E> c)
int
drainTo(java.util.Collection<? super E> c, int maxElements)
boolean
isEmpty()
java.util.Iterator<E>
iterator()
protected java.util.Queue<E>
newQueue()
Create a new single-producer multiple-consumer thread-safe queueboolean
offer(E e)
boolean
offer(E e, long timeout, java.util.concurrent.TimeUnit unit)
E
peek()
E
poll()
E
poll(long timeout, java.util.concurrent.TimeUnit unit)
void
put(E e)
int
remainingCapacity()
Returns Integer.MAX_VALUE because this is an unbounded queue.boolean
remove(java.lang.Object o)
boolean
removeIf(java.util.function.Predicate<? super E> filter)
int
size()
E
take()
-
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:
put
in 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:
offer
in interfacejava.util.concurrent.BlockingQueue<E>
- Throws:
java.lang.InterruptedException
-
take
@Nonnull public E take() throws java.lang.InterruptedException
- Specified by:
take
in 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:
poll
in 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:
remainingCapacity
in interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
public int drainTo(@Nonnull java.util.Collection<? super E> c)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
public int drainTo(@Nonnull java.util.Collection<? super E> c, int maxElements)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<E>
-
offer
public boolean offer(E e)
-
remove
public boolean remove(java.lang.Object o)
-
-