K
- the type of the conflation keyV
- the type of elements in the queuepublic class EvictConflationQueue<K,V> extends java.lang.Object implements ExchangeConflationQueue<K,V>
AtomicConflationQueue
is very similar but this queue implements
ExchangeConflationQueue
and hence supports value exchange between producer and consumer. The backing queue
is supplied to the constructor and it determines whether single or multiple producers and consumers are supported.
Each producer should acquire its own appender
from the producing thread, and similarly every
consumer should call poller()
from the consuming thread. Note that appender listener and poller listener
must be thread safe if multiple producers or consumers are used, e.g. use
AppenderListener.threadLocalSupplier(Supplier)
and PollerListener.threadLocalSupplier(Supplier)
to
create separate listener instances per producer/consumer thread.
ExchangeConflationQueue.ExchangePoller<K,V>
ConflationQueue.Appender<K,V>, ConflationQueue.Poller<K,V>
Constructor and Description |
---|
EvictConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory)
Constructor with queue factory.
|
EvictConflationQueue(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.
|
EvictConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
java.util.List<? extends K> allConflationKeys,
java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier,
java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
Constructor with queue factory and the exhaustive list of conflation keys.
|
EvictConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier,
java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
Constructor with queue factory.
|
EvictConflationQueue(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,
java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier,
java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
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,
java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier,
java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
Static constructor method for a conflation queue with queue factory and the conflation key enum class.
|
ExchangeConflationQueue.ExchangePoller<K,V> |
poller()
Returns the poller object used by the consumer to poll values.
|
int |
size()
Returns the number of elements in this queue.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
nullSafe, nullSafe
public EvictConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory)
queueFactory
- the factory to create the backing queuepublic EvictConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier, java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
queueFactory
- the factory to create the backing queueappenderListenerSupplier
- a supplier for a listener to monitor the enqueue operationspollerListenerSupplier
- a supplier for a listener to monitor the poll operationspublic EvictConflationQueue(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, java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier, java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
queueFactory
- the factory to create the backing queueentryMapFactory
- the factory to create the map that manages entries per conflation keyappenderListenerSupplier
- a supplier for a listener to monitor the enqueue operationspollerListenerSupplier
- a supplier for a listener to monitor the poll operationspublic EvictConflationQueue(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 EvictConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, java.util.List<? extends K> allConflationKeys, java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier, java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
queueFactory
- the factory to create the backing queueallConflationKeys
- all conflation keys that will ever be used with this conflation queue instanceappenderListenerSupplier
- a supplier for a listener to monitor the enqueue operationspollerListenerSupplier
- a supplier for a listener to monitor the poll operationspublic static <K extends java.lang.Enum<K>,V> EvictConflationQueue<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> EvictConflationQueue<K,V> forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, java.lang.Class<K> conflationKeyClass, java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier, java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
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 classappenderListenerSupplier
- a supplier for a listener to monitor the enqueue operationspollerListenerSupplier
- a supplier for a listener to monitor the poll operationspublic ConflationQueue.Appender<K,V> appender()
ConflationQueue
appender
in interface ConflationQueue<K,V>
appender
in interface ExchangeConflationQueue<K,V>
public ExchangeConflationQueue.ExchangePoller<K,V> poller()
ConflationQueue
poller
in interface ConflationQueue<K,V>
poller
in interface ExchangeConflationQueue<K,V>
public int size()
ConflationQueue
Beware 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>