Class QueuePipe<T>

  • Type Parameters:
    T - The item data type
    All Implemented Interfaces:
    Closeable, AutoCloseable, BasePipe, Pipe<T>

    public class QueuePipe<T>
    extends CompoundPipe<T>
    An intermediate pipe that actively pulls items from the input pipe and stores in a queue for the downstream pipe to fetch. The threading model is a little different from other synchronous pipes: all upstream pipes are handled by an internal thread (the "produced thread" feeding the queue), while all actions on this pipe are handled by the caller's thread. Therefore, positioning a QueuePipe in a flow will break the flow into producer part and consumer part, each of them handled by a different thread.
    Author:
    Eyal Schneider
    • Constructor Detail

      • QueuePipe

        public QueuePipe​(Pipe<T> inputPipe,
                         BlockingQueue<QueueItem<T>> queue)
        Constructor
        Parameters:
        inputPipe - The input pipe to pull items from
        queue - The queue to store data available for pulling from this pipe. Be careful with unbounded queues.
      • QueuePipe

        public QueuePipe​(Pipe<T> inputPipe,
                         int queueCapacity)
        Constructor
        Parameters:
        inputPipe - The input pipe to pull items from
        queueCapacity - The capacity to use for the internal queue. Uses a LinkedBlockingQueue.