org.apache.uima.collection.impl.cpm.engine
Class BoundedWorkQueue

java.lang.Object
  extended by org.apache.uima.collection.impl.cpm.engine.BoundedWorkQueue
Direct Known Subclasses:
SequencedQueue

public class BoundedWorkQueue
extends java.lang.Object

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
protected  CPMEngine cpm
           
protected  int numberElementsInQueue
           
protected  java.util.LinkedList queue
           
protected  int queueMaxSize
           
protected  java.lang.String queueName
           
protected static int WAIT_TIMEOUT
           
 
Constructor Summary
BoundedWorkQueue(int aQueueSize, java.lang.String aQueueName, CPMEngine aCpmEngine)
          Initialize the instance
 
Method Summary
 java.lang.Object dequeue()
          Removes an object from the front of the queue according to FIFO.
 java.lang.Object dequeue(long aTimeout)
          Returns an object from the queue.
 void enqueue(java.lang.Object anObject)
          Enqueues a given object onto the queue.
 int getCapacity()
          Returns the queue capacity
 int getCurrentSize()
          Returns number of elements in the queue.
 java.lang.String getName()
          Returns Queue name
 void invalidate(CAS[] aCasObjectList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queueMaxSize

protected final int queueMaxSize

queue

protected java.util.LinkedList queue

numberElementsInQueue

protected int numberElementsInQueue

queueName

protected java.lang.String queueName

cpm

protected CPMEngine cpm

WAIT_TIMEOUT

protected static final int WAIT_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

BoundedWorkQueue

public BoundedWorkQueue(int aQueueSize,
                        java.lang.String aQueueName,
                        CPMEngine aCpmEngine)
Initialize the instance

Parameters:
aQueueSize - - fixed size for this queue (capacity)
aQueueName - - name for this queue
aCpmEngine - - CPE Engine reference
Method Detail

getName

public java.lang.String 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

public void enqueue(java.lang.Object anObject)
Enqueues a given object onto the queue. It blocks if the queue is full.

Parameters:
anObject - - an object to enqueue

dequeue

public java.lang.Object dequeue()
Removes an object from the front of the queue according to FIFO.

Returns:
object dequeued from the head of the queue

dequeue

public java.lang.Object dequeue(long aTimeout)
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

public void invalidate(CAS[] aCasObjectList)


Copyright © 2010 The Apache Software Foundation. All Rights Reserved.