DATATYPE - The type of the objects in the queue.@ThreadSafe public abstract class AbstractConcurrentCollector<DATATYPE> extends Object implements INonThrowingRunnable, IMutableConcurrentCollector<DATATYPE>
BlockingQueue.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_QUEUE_SIZE
Default maximum queue size
|
protected BlockingQueue<Object> |
m_aQueue |
static Object |
STOP_QUEUE_OBJECT
The STOP object that is internally added to the queue to indicate the last
token
|
| Constructor and Description |
|---|
AbstractConcurrentCollector(BlockingQueue<Object> aQueue)
Constructor using an arbitrary
BlockingQueue. |
AbstractConcurrentCollector(int nMaxQueueSize)
Constructor creating an
ArrayBlockingQueue internally. |
| Modifier and Type | Method and Description |
|---|---|
List<DATATYPE> |
drainQueue() |
int |
getQueueLength() |
boolean |
isQueueEmpty() |
boolean |
isStopped()
Check if this collector is already stopped.
|
ESuccess |
queueObject(DATATYPE aObject)
Submit an object to the queue.
|
ESuccess |
stopQueuingNewObjects()
Stop taking new objects in the collector.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrunpublic static final int DEFAULT_MAX_QUEUE_SIZE
public static final Object STOP_QUEUE_OBJECT
protected final BlockingQueue<Object> m_aQueue
public AbstractConcurrentCollector(@Nonnegative int nMaxQueueSize)
ArrayBlockingQueue internally.nMaxQueueSize - The maximum number of items that can be in the queue. Must be >
0.public AbstractConcurrentCollector(@Nonnull BlockingQueue<Object> aQueue)
BlockingQueue.aQueue - The BlockingQueue to be used. May not be null.@Nonnull public final ESuccess queueObject(@Nonnull DATATYPE aObject)
IMutableConcurrentCollectorqueueObject in interface IMutableConcurrentCollector<DATATYPE>aObject - The object to submit. May not be null.ESuccesspublic boolean isQueueEmpty()
isQueueEmpty in interface IConcurrentCollector<DATATYPE>true if the queue is empty, false
otherwise.@Nonnegative public final int getQueueLength()
getQueueLength in interface IConcurrentCollector<DATATYPE>@Nonnull public final ESuccess stopQueuingNewObjects()
IMutableConcurrentCollectorstopQueuingNewObjects in interface IMutableConcurrentCollector<DATATYPE>ESuccesspublic final boolean isStopped()
IConcurrentCollectorisStopped in interface IConcurrentCollector<DATATYPE>true if the collector is stopped, false
otherwise.@Nonnull @ReturnsMutableCopy public final List<DATATYPE> drainQueue()
Copyright © 2014–2015 Philip Helger. All rights reserved.