Class BoundedWorkQueue

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

public class BoundedWorkQueue extends 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 Details

    • queueMaxSize

      protected final int queueMaxSize
      The queue max size.
    • queue

      protected List<Object> queue
      The queue.
    • numberElementsInQueue

      protected int numberElementsInQueue
      The number elements in queue.
    • queueName

      protected String queueName
      The queue name.
    • cpm

      protected CPMEngine cpm
      The cpm.
    • WAIT_TIMEOUT

      protected static final int WAIT_TIMEOUT
      The Constant WAIT_TIMEOUT.
      See Also:
  • Constructor Details

    • BoundedWorkQueue

      public BoundedWorkQueue(int aQueueSize, 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 Details

    • getName

      public 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(Object anObject)
      Enqueues a given object onto the queue. It blocks if the queue is full.
      Parameters:
      anObject - - an object to enqueue
    • dequeue

      public 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 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)
      Invalidate.
      Parameters:
      aCasObjectList - the a cas object list