Class AbstractAsyncWriter<T>

java.lang.Object
htsjdk.samtools.util.AbstractAsyncWriter<T>
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
AsyncFastqWriter, AsyncVariantContextWriter

public abstract class AbstractAsyncWriter<T> extends Object implements Closeable
Abstract class that is designed to be extended and specialized to provide an asynchronous wrapper around any kind of Writer class that takes an object and writes it out somehow. NOTE: Objects of subclasses of this class are not intended to be shared between threads. In particular there must be only one thread that calls write(T) and close(). NOTE: Any exception thrown by the underlying Writer will be propagated back to the caller during the next available call to write(T) or close(). After the exception has been thrown to the caller, it is not safe to attempt further operations on the instance.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractAsyncWriter(int queueSize)
    Creates an AbstractAsyncWriter that will use the provided WriterRunnable to consume from the internal queue and write records into the synchronous writer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Attempts to finish draining the queue and then calls synchronouslyClose() to allow implementation to do any one time clean up.
    protected abstract String
    Returns the prefix to use when naming threads.
    protected abstract void
     
    protected abstract void
     
    void
    write(T item)
    Public method for sub-classes or ultimately consumers to put an item into the queue to be written out.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • AbstractAsyncWriter

      protected AbstractAsyncWriter(int queueSize)
      Creates an AbstractAsyncWriter that will use the provided WriterRunnable to consume from the internal queue and write records into the synchronous writer.
  • Method Details

    • getThreadNamePrefix

      protected abstract String getThreadNamePrefix()
      Returns the prefix to use when naming threads.
    • synchronouslyWrite

      protected abstract void synchronouslyWrite(T item)
    • synchronouslyClose

      protected abstract void synchronouslyClose()
    • write

      public void write(T item)
      Public method for sub-classes or ultimately consumers to put an item into the queue to be written out.
    • close

      public void close()
      Attempts to finish draining the queue and then calls synchronouslyClose() to allow implementation to do any one time clean up.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable