Class SyncProcessingQueue<T>


  • public class SyncProcessingQueue<T>
    extends Object
    Multiple producer-single consumer queue. The producers are expected to call pushAndWait(), the consumer should call pop() in a loop and if a null is returned (meaning that the queue is either empty, to call notifyAndWait(). Example: while (running) { T element = queue.pop(); if (element != null) { process(element); } else { flush(); queue.notifyAndWait(); } } // terminate producers and process the rest of the queue queue.notifyNoWait();
    Author:
    Radim Vansa <rvansa@redhat.com>, Francesco Nigro <fnigro@redhat.com>
    • Constructor Detail

      • SyncProcessingQueue

        public SyncProcessingQueue()
    • Method Detail

      • pop

        public T pop()
      • notifyNoWait

        public void notifyNoWait()
      • notifyAndWait

        public boolean notifyAndWait()
        Returns:
        {code true} if not empty or false if the consumer Thread is interrupted
      • notifyError

        public void notifyError()