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:
Iterable<E>
,Collection<E>
,BlockingQueue<E>
,Queue<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
ConstructorDescriptionDefault constructor with a pollSleepMillis of 10 milliseconds.ConcurrentLinkedBlockingQueue
(long pollSleepMillis) Constructor which permits specifying the pollSleepMillis -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
int
drainTo
(Collection<? super E> c) int
drainTo
(Collection<? super E> c, int maxElements) boolean
isEmpty()
iterator()
newQueue()
Create a new single-producer multiple-consumer thread-safe queueboolean
boolean
peek()
poll()
void
int
Returns Integer.MAX_VALUE because this is an unbounded queue.boolean
boolean
int
size()
take()
Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
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
Methods inherited from interface java.util.concurrent.BlockingQueue
add, contains
Methods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, parallelStream, removeAll, retainAll, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
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 Details
-
newQueue
Create a new single-producer multiple-consumer thread-safe queue- Returns:
- new queue instance.
-
iterator
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Overrides:
clear
in classAbstractQueue<E>
-
put
- Specified by:
put
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
offer
- Specified by:
offer
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
take
- Specified by:
take
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
poll
- Specified by:
poll
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()Returns Integer.MAX_VALUE because this is an unbounded queue.- Specified by:
remainingCapacity
in interfaceBlockingQueue<E>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<E>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<E>
-
offer
-
poll
-
peek
-
remove
- Specified by:
remove
in interfaceBlockingQueue<E>
- Specified by:
remove
in interfaceCollection<E>
- Overrides:
remove
in classAbstractCollection<E>
-
removeIf
- Specified by:
removeIf
in interfaceCollection<E>
-