K - the type of the conflation keyV - the type of elements in the queuepublic class AtomicConflationQueue<K,V> extends java.lang.Object implements ConflationQueue<K,V>
EvictConflationQueue is very similar but not atomic and it supports value exchange
on polling, which this queue does not. A backing queue is supplied to the constructor and it determines whether
single or multiple producers and consumers are supported.
Appender and poller() are both stateless and hence thread-safe. Note that appender
listener and poller listener must also be thread safe if multiple producers or consumers are used, e.g. use
AppenderListener.threadLocal(Supplier) and PollerListener.threadLocal(Supplier) to create thread
local listener instances.
ConflationQueue.Appender<K,V>, ConflationQueue.Poller<K,V>| Constructor and Description |
|---|
AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory)
Constructor with queue factory.
|
AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
AppenderListener<? super K,? super V> appenderListener,
PollerListener<? super K,? super V> pollerListener)
Constructor with queue factory.
|
AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
java.util.List<? extends K> allConflationKeys)
Constructor with queue factory and the exhaustive list of conflation keys.
|
AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
java.util.List<? extends K> allConflationKeys,
AppenderListener<? super K,? super V> appenderListener,
PollerListener<? super K,? super V> pollerListener)
Constructor with queue factory and the exhaustive list of conflation keys.
|
AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
java.util.function.Supplier<? extends java.util.Map<java.lang.Object,java.lang.Object>> entryMapFactory,
AppenderListener<? super K,? super V> appenderListener,
PollerListener<? super K,? super V> pollerListener)
Constructor with queue factory and entry map factory.
|
| Modifier and Type | Method and Description |
|---|---|
ConflationQueue.Appender<K,V> |
appender()
Returns the appender object used by the producer to enqueue values.
|
static <K extends java.lang.Enum<K>,V> |
forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
java.lang.Class<K> conflationKeyClass)
Static constructor method for a conflation queue with queue factory and the conflation key enum class.
|
static <K extends java.lang.Enum<K>,V> |
forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
java.lang.Class<K> conflationKeyClass,
AppenderListener<? super K,? super V> appenderListener,
PollerListener<? super K,? super V> pollerListener)
Static constructor method for a conflation queue with queue factory and the conflation key enum class.
|
ConflationQueue.Poller<K,V> |
poller()
Returns the poller object used by the consumer to poll values.
|
int |
size()
Returns the number of elements in this queue.
|
public AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory)
queueFactory - the factory to create the backing queuepublic AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, AppenderListener<? super K,? super V> appenderListener, PollerListener<? super K,? super V> pollerListener)
queueFactory - the factory to create the backing queueappenderListener - a listener to monitor the enqueue operationspollerListener - a listener to monitor the poll operationspublic AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, java.util.function.Supplier<? extends java.util.Map<java.lang.Object,java.lang.Object>> entryMapFactory, AppenderListener<? super K,? super V> appenderListener, PollerListener<? super K,? super V> pollerListener)
queueFactory - the factory to create the backing queueentryMapFactory - the factory to create the map that manages entries per conflation keyappenderListener - a listener to monitor the enqueue operationspollerListener - a listener to monitor the poll operationspublic AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, java.util.List<? extends K> allConflationKeys)
queueFactory - the factory to create the backing queueallConflationKeys - all conflation keys that will ever be used with this conflation queue instancepublic AtomicConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, java.util.List<? extends K> allConflationKeys, AppenderListener<? super K,? super V> appenderListener, PollerListener<? super K,? super V> pollerListener)
queueFactory - the factory to create the backing queueallConflationKeys - all conflation keys that will ever be used with this conflation queue instanceappenderListener - a listener to monitor the enqueue operationspollerListener - a listener to monitor the poll operationspublic static <K extends java.lang.Enum<K>,V> AtomicConflationQueue<K,V> forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, java.lang.Class<K> conflationKeyClass)
K - the type of the conflation keyV - the type of elements in the queuequeueFactory - the factory to create the backing queueconflationKeyClass - the conflation key enum classpublic static <K extends java.lang.Enum<K>,V> AtomicConflationQueue<K,V> forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, java.lang.Class<K> conflationKeyClass, AppenderListener<? super K,? super V> appenderListener, PollerListener<? super K,? super V> pollerListener)
K - the type of the conflation keyV - the type of elements in the queuequeueFactory - the factory to create the backing queueconflationKeyClass - the conflation key enum classappenderListener - a listener to monitor the enqueue operationspollerListener - a listener to monitor the poll operationspublic ConflationQueue.Appender<K,V> appender()
ConflationQueueappender in interface ConflationQueue<K,V>public ConflationQueue.Poller<K,V> poller()
ConflationQueuepoller in interface ConflationQueue<K,V>public int size()
ConflationQueueBeware that, unlike in most collections, this method may NOT be a constant-time operation. Because of the asynchronous nature of concurrent queues, determining the current number of elements may require an O(n) traversal. Additionally, if elements are added or removed during execution of this method, the returned result may be inaccurate. Thus, this method is typically not very useful in concurrent applications.
size in interface ConflationQueue<K,V>