Class BoundedWorkQueue
java.lang.Object
org.apache.uima.collection.impl.cpm.engine.BoundedWorkQueue
- Direct Known Subclasses:
SequencedQueue
Implementation of a Bounded Queue, a queue with a fixed number of slots. Used primarily to feed
data to Processing Units, it is filled by a producer like ArtifactProducer and consumed by
ProcessingUnit(s). When the queue is full it will block a request for enqueue until a slot frees
up.
There are 2 dequeue calls. One returns null if the queue is empty, the other can be given a timeout - and it will wait up to that time waiting for something to get enqueued.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionBoundedWorkQueue
(int aQueueSize, String aQueueName, CPMEngine aCpmEngine) Initialize the instance. -
Method Summary
Modifier and TypeMethodDescriptiondequeue()
Removes an object from the front of the queue according to FIFO.dequeue
(long aTimeout) Returns an object from the queue.void
Enqueues a given object onto the queue.int
Returns the queue capacity.int
Returns number of elements in the queue.getName()
Returns Queue name.void
invalidate
(CAS[] aCasObjectList) Invalidate.
-
Field Details
-
queueMaxSize
protected final int queueMaxSizeThe queue max size. -
queue
The queue. -
numberElementsInQueue
protected int numberElementsInQueueThe number elements in queue. -
queueName
The queue name. -
cpm
The cpm. -
WAIT_TIMEOUT
protected static final int WAIT_TIMEOUTThe Constant WAIT_TIMEOUT.- See Also:
-
-
Constructor Details
-
BoundedWorkQueue
Initialize the instance.- Parameters:
aQueueSize
- - fixed size for this queue (capacity)aQueueName
- - name for this queueaCpmEngine
- - CPE Engine reference
-
-
Method Details
-
getName
Returns Queue name.- Returns:
- - name of the queue
-
getCurrentSize
public int getCurrentSize()Returns number of elements in the queue. Special case handles EOFToken.- Returns:
- - number of elements in the queue
-
getCapacity
public int getCapacity()Returns the queue capacity.- Returns:
- - queue max size
-
enqueue
Enqueues a given object onto the queue. It blocks if the queue is full.- Parameters:
anObject
- - an object to enqueue
-
dequeue
Removes an object from the front of the queue according to FIFO.- Returns:
- object dequeued from the head of the queue
-
dequeue
Returns an object from the queue. It will wait for the object to show up in the queue until a given timer expires.- Parameters:
aTimeout
- - max millis to wait for an object- Returns:
- - Object from the queue, or null if time out
-
invalidate
Invalidate.- Parameters:
aCasObjectList
- the a cas object list
-