Class QueuedWriter<T>

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ToFileWriter<T>

    final class QueuedWriter<T>
    extends java.lang.Object
    implements ToFileWriter<T>
    • Constructor Summary

      Constructors 
      Constructor Description
      QueuedWriter​(java.util.concurrent.ExecutorService executor, java.util.concurrent.BlockingQueue<T> queue, ToFileWriter<T>... writers)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      (package private) int drainTo​(java.util.List<T> batchContainer)  
      (package private) boolean isMoreToCome()  
      (package private) java.util.List<T> newBatchContainer()  
      void write​(T item)
      Write the item to the consumer.
      • Methods inherited from class java.lang.Object

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

      • myActive

        private volatile boolean myActive
      • myBatchSize

        private final int myBatchSize
      • myFutures

        private final java.util.concurrent.Future<?>[] myFutures
      • myQueue

        private final java.util.concurrent.BlockingQueue<T> myQueue
    • Constructor Detail

      • QueuedWriter

        QueuedWriter​(java.util.concurrent.ExecutorService executor,
                     java.util.concurrent.BlockingQueue<T> queue,
                     ToFileWriter<T>... writers)
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface ToFileWriter<T>
        Throws:
        java.io.IOException
      • write

        public void write​(T item)
        Description copied from interface: ToFileWriter
        Write the item to the consumer.
        Specified by:
        write in interface ToFileWriter<T>
        Parameters:
        item - The item to be written
      • drainTo

        int drainTo​(java.util.List<T> batchContainer)
      • isMoreToCome

        boolean isMoreToCome()
      • newBatchContainer

        java.util.List<T> newBatchContainer()