Class 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.
    • Constructor Detail

      • 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 Detail

      • 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