public final class MPMCBlockingQueue<E> extends Object implements Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>, ConcurrentQueue<E>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
MPMCConcurrentQueue.Cell<R> |
| Modifier and Type | Field and Description |
|---|---|
protected com.conversantmedia.util.concurrent.Condition |
queueNotEmptyCondition |
protected com.conversantmedia.util.concurrent.Condition |
queueNotFullCondition |
protected int |
size |
| Constructor and Description |
|---|
MPMCBlockingQueue(int capacity)
Construct a blocking queue of the given fixed capacity.
|
MPMCBlockingQueue(int capacity,
Collection<? extends E> c)
Construct a blocking queue of the given fixed capacity
|
MPMCBlockingQueue(int capacity,
SpinPolicy spinPolicy)
Construct a blocking queue with a given fixed capacity
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
int |
capacity() |
void |
clear()
clear the queue of all elements
|
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
int |
drainTo(Collection<? super E> c) |
int |
drainTo(Collection<? super E> c,
int maxElements) |
E |
element() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
offer(E e)
Add element t to the ring
|
boolean |
offer(E e,
long timeout,
TimeUnit unit) |
E |
peek()
return the first element in the queue
|
E |
poll()
remove the first element from the queue and return it
|
E |
poll(long timeout,
TimeUnit unit) |
void |
put(E e) |
int |
remainingCapacity() |
E |
remove() |
int |
remove(E[] e)
return all elements in the queue to the provided array, up to the size of the provided
array.
|
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
E |
take() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontainsequals, hashCode, isEmpty, parallelStream, removeIf, size, streamprotected final com.conversantmedia.util.concurrent.Condition queueNotFullCondition
protected final com.conversantmedia.util.concurrent.Condition queueNotEmptyCondition
protected final int size
public MPMCBlockingQueue(int capacity)
Construct a blocking queue of the given fixed capacity.
Note: actual capacity will be the next power of two larger than capacity.capacity - maximum capacity of this queuepublic MPMCBlockingQueue(int capacity,
SpinPolicy spinPolicy)
Construct a blocking queue with a given fixed capacity
Note: actual capacity will be the next power of two larger than capacity. Waiting locking may be used in servers that are tuned for it, waiting locking provides a high performance locking implementation which is approximately a factor of 2 improvement in throughput (40M/s for 1-1 thread transfers) However waiting locking is more CPU aggressive and causes servers that may be configured with far too many threads to show very high load averages. This is probably not as detrimental as it is annoying.capacity - - the queue capacity, suggest using a power of 2spinPolicy - - determine the level of cpu aggressiveness in waitingpublic MPMCBlockingQueue(int capacity,
Collection<? extends E> c)
Construct a blocking queue of the given fixed capacity
Note: actual capacity will be the next power of two larger than capacity.
The values from the collection, c, are appended to the queue in iteration order. If the number of elements in the collection exceeds the actual capacity, then the additional elements overwrite the previous ones until all elements have been written once.capacity - maximum capacity of this queuec - A collection to use to populate inital valuespublic final boolean offer(E e)
ConcurrentQueueoffer in interface ConcurrentQueue<E>offer in interface BlockingQueue<E>offer in interface Queue<E>e - - element to offerpublic final E poll()
ConcurrentQueuepublic int remove(E[] e)
ConcurrentQueueremove in interface ConcurrentQueue<E>e - - The element arraypublic void put(E e) throws InterruptedException
put in interface BlockingQueue<E>InterruptedExceptionpublic boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
offer in interface BlockingQueue<E>InterruptedExceptionpublic E take() throws InterruptedException
take in interface BlockingQueue<E>InterruptedExceptionpublic E poll(long timeout, TimeUnit unit) throws InterruptedException
poll in interface BlockingQueue<E>InterruptedExceptionpublic void clear()
ConcurrentQueueclear in interface ConcurrentQueue<E>clear in interface Collection<E>public int remainingCapacity()
remainingCapacity in interface BlockingQueue<E>public int drainTo(Collection<? super E> c)
drainTo in interface BlockingQueue<E>public int drainTo(Collection<? super E> c, int maxElements)
drainTo in interface BlockingQueue<E>public Object[] toArray()
toArray in interface Collection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>public boolean add(E e)
add in interface Collection<E>add in interface BlockingQueue<E>add in interface Queue<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface BlockingQueue<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>public final E peek()
ConcurrentQueuepeek in interface ConcurrentQueue<E>public final int size()
size in interface ConcurrentQueue<E>public int capacity()
capacity in interface ConcurrentQueue<E>public final boolean isEmpty()
isEmpty in interface ConcurrentQueue<E>public final boolean contains(Object o)
contains in interface ConcurrentQueue<E>o - - the object to testCopyright © 2012–2018 Conversant Engineering. All rights reserved.