Class AsyncCollectionWriterPipe<T>

  • All Implemented Interfaces:
    Closeable, AutoCloseable, BasePipe

    public class AsyncCollectionWriterPipe<T>
    extends TerminalPipe
    A terminal async pipe writing all contents from an input pipe into a given collection. Thread safety: It's the responsibility of the caller to use a thread safe collection!
    Author:
    Eyal Schneider
    • Constructor Detail

      • AsyncCollectionWriterPipe

        public AsyncCollectionWriterPipe​(AsyncPipe<T> input,
                                         Collection<T> outputCollection)
        Constructor
        Parameters:
        input - The input pipe
        outputCollection - The output collection to write items to. Must be thread safe!
      • AsyncCollectionWriterPipe

        public AsyncCollectionWriterPipe​(AsyncPipe<T> input)
        Constructor Collects items into a thread safe List created internally.
        Parameters:
        input - The input pipe
    • Method Detail

      • start

        public void start()
                   throws PipeException,
                          InterruptedException
        Description copied from interface: BasePipe
        Performs pre-processing prior to item flow throw the pipe. Implementations must call the same method for all their input pipes before accessing their items. This is typically done here.
        Throws:
        PipeException - In case of pipe errors in this pipe or somewhere up-stream.
        InterruptedException - In case that the operation has been interrupted by another thread.
      • getItems

        public Collection<T> getItems()
        Returns:
        The collection given in the constructor