Class AsyncBufferedIterator<T>

java.lang.Object
htsjdk.samtools.util.AsyncBufferedIterator<T>
All Implemented Interfaces:
CloseableIterator<T>, Closeable, AutoCloseable, Iterator<T>

public class AsyncBufferedIterator<T> extends Object implements CloseableIterator<T>
Iterator that uses a dedicated background thread to perform read-ahead to improve throughput at the expense of increased latency. This iterator will block until the background thread has read a full buffer of records. Note that this implementation is not synchronized. If multiple threads access an instance concurrently, it must be synchronized externally.
  • Constructor Details

    • AsyncBufferedIterator

      public AsyncBufferedIterator(Iterator<T> iterator, int bufferSize)
      Creates a new iterator that traverses the given iterator on a background thread
      Parameters:
      iterator - iterator to traverse
      bufferSize - size of read-ahead buffer. A larger size will increase both throughput and latency. Double buffering is used so the maximum number of records on which read-ahead is performed is twice this.
    • AsyncBufferedIterator

      public AsyncBufferedIterator(Iterator<T> iterator, int bufferSize, int bufferCount)
      Creates a new iterator that traverses the given iterator on a background thread
      Parameters:
      iterator - iterator to traverse
      bufferSize - size of each read-ahead buffer. A larger size will increase both throughput and latency.
      bufferCount - number of read-ahead buffers
    • AsyncBufferedIterator

      public AsyncBufferedIterator(Iterator<T> iterator, int bufferSize, int bufferCount, String threadName)
      Creates a new iterator that traverses the given iterator on a background thread
      Parameters:
      iterator - iterator to traverse
      bufferSize - size of each read-ahead buffer. A larger size will increase both throughput and latency.
      bufferCount - number of read-ahead buffers
      threadName - background thread name. A name will be automatically generated if this parameter is null.
  • Method Details