Class 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

      Fields 
      Modifier and Type Field Description
      protected CPMEngine cpm
      The cpm.
      private static Logger LOG  
      protected int numberElementsInQueue
      The number elements in queue.
      protected java.util.List<java.lang.Object> queue
      The queue.
      protected int queueMaxSize
      The queue max size.
      protected java.lang.String queueName
      The queue name.
      protected static int WAIT_TIMEOUT
      The Constant WAIT_TIMEOUT.
    • Constructor Summary

      Constructors 
      Constructor Description
      BoundedWorkQueue​(int aQueueSize, java.lang.String aQueueName, CPMEngine aCpmEngine)
      Initialize the instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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)
      Invalidate.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final Logger LOG
      • queueMaxSize

        protected final int queueMaxSize
        The queue max size.
      • queue

        protected java.util.List<java.lang.Object> queue
        The queue.
      • numberElementsInQueue

        protected int numberElementsInQueue
        The number elements in queue.
      • queueName

        protected java.lang.String queueName
        The queue name.
      • WAIT_TIMEOUT

        protected static final int WAIT_TIMEOUT
        The Constant 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)
        Invalidate.
        Parameters:
        aCasObjectList - the a cas object list