Class AbstractConcurrentCollector<DATATYPE>
java.lang.Object
com.helger.commons.concurrent.collector.AbstractConcurrentCollector<DATATYPE>
- Type Parameters:
DATATYPE- The type of the objects in the queue.
- All Implemented Interfaces:
IConcurrentCollector,IMutableConcurrentCollector<DATATYPE>
- Direct Known Subclasses:
ConcurrentCollectorMultiple,ConcurrentCollectorSingle
@ThreadSafe
public abstract class AbstractConcurrentCollector<DATATYPE>
extends Object
implements IMutableConcurrentCollector<DATATYPE>
Abstract concurrent collector based on
BlockingQueue.- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum queue sizeprotected final BlockingQueue<Object> static final ObjectThe STOP object that is internally added to the queue to indicate the last token. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConcurrentCollector(int nMaxQueueSize) Constructor creating anArrayBlockingQueueinternally.protectedConstructor using an arbitraryBlockingQueue. -
Method Summary
Modifier and TypeMethodDescriptionfinal ICommonsList<DATATYPE> final intbooleanfinal booleanCheck if this collector is already stopped.final ESuccessqueueObject(DATATYPE aObject) Submit an object to the queue.final ESuccessStop taking new objects in the collector.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.commons.concurrent.collector.IMutableConcurrentCollector
collect
-
Field Details
-
DEFAULT_MAX_QUEUE_SIZE
public static final int DEFAULT_MAX_QUEUE_SIZEDefault maximum queue size- See Also:
-
STOP_QUEUE_OBJECT
The STOP object that is internally added to the queue to indicate the last token. Should implement Comparable for the priority queue -
m_aQueue
-
-
Constructor Details
-
AbstractConcurrentCollector
Constructor creating anArrayBlockingQueueinternally.- Parameters:
nMaxQueueSize- The maximum number of items that can be in the queue. Must be > 0.
-
AbstractConcurrentCollector
Constructor using an arbitraryBlockingQueue.- Parameters:
aQueue- TheBlockingQueueto be used. May not benull.
-
-
Method Details
-
queueObject
Description copied from interface:IMutableConcurrentCollectorSubmit an object to the queue.- Specified by:
queueObjectin interfaceIMutableConcurrentCollector<DATATYPE>- Parameters:
aObject- The object to submit. May not benull.- Returns:
ESuccess
-
isQueueEmpty
public boolean isQueueEmpty()- Specified by:
isQueueEmptyin interfaceIConcurrentCollector- Returns:
trueif the queue is empty,falseotherwise.
-
getQueueLength
- Specified by:
getQueueLengthin interfaceIConcurrentCollector- Returns:
- The number of objects currently in the queue.
-
stopQueuingNewObjects
Description copied from interface:IMutableConcurrentCollectorStop taking new objects in the collector. Returns directly and does not wait until the processing finished.- Specified by:
stopQueuingNewObjectsin interfaceIMutableConcurrentCollector<DATATYPE>- Returns:
ESuccess
-
isStopped
public final boolean isStopped()Description copied from interface:IConcurrentCollectorCheck if this collector is already stopped.- Specified by:
isStoppedin interfaceIConcurrentCollector- Returns:
trueif the collector is stopped,falseotherwise.
-
drainQueue
-