Class LinkedBlockingStream<T>

java.lang.Object
fr.lirmm.graphik.util.stream.AbstractCloseableIterator<T>
fr.lirmm.graphik.util.stream.LinkedBlockingStream<T>
Type Parameters:
T - type of elements stored in the stream
All Implemented Interfaces:
CloseableIterator<T>, Writer<T>, Closeable, AutoCloseable

public class LinkedBlockingStream<T> extends AbstractCloseableIterator<T> implements Writer<T>
Concurrent in-memory stream backed by a linked queue.
Author:
Clément Sipieter (INRIA) clement@6pi.fr
  • Constructor Details

    • LinkedBlockingStream

      public LinkedBlockingStream()
      Creates a blocking stream with the default queue bounds.
  • Method Details

    • write

      public void write(T object)
      Description copied from interface: Writer
      Writes a single object.
      Specified by:
      write in interface Writer<T>
      Parameters:
      object - the object to write
    • hasNext

      public boolean hasNext()
      Description copied from interface: CloseableIterator
      Returns whether another element is available.
      Specified by:
      hasNext in interface CloseableIterator<T>
      Returns:
      true if another element can be read
    • next

      public T next()
      Description copied from interface: CloseableIterator
      Returns the next element.
      Specified by:
      next in interface CloseableIterator<T>
      Returns:
      the next element
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface CloseableIterator<T>
    • write

      public void write(Iterator<T> it) throws IOException
      Description copied from interface: Writer
      Writes all objects provided by the iterator.
      Specified by:
      write in interface Writer<T>
      Parameters:
      it - the objects to write
      Throws:
      IOException - if the write fails