Package htsjdk.samtools.util
Class AsyncBufferedIterator<T>
java.lang.Object
htsjdk.samtools.util.AsyncBufferedIterator<T>
- All Implemented Interfaces:
CloseableIterator<T>,Closeable,AutoCloseable,Iterator<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 Summary
ConstructorsConstructorDescriptionAsyncBufferedIterator(Iterator<T> iterator, int bufferSize) Creates a new iterator that traverses the given iterator on a background threadAsyncBufferedIterator(Iterator<T> iterator, int bufferSize, int bufferCount) Creates a new iterator that traverses the given iterator on a background threadAsyncBufferedIterator(Iterator<T> iterator, int bufferSize, int bufferCount, String threadName) Creates a new iterator that traverses the given iterator on a background thread -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface htsjdk.samtools.util.CloseableIterator
stream, toListMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
AsyncBufferedIterator
Creates a new iterator that traverses the given iterator on a background thread- Parameters:
iterator- iterator to traversebufferSize- 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
Creates a new iterator that traverses the given iterator on a background thread- Parameters:
iterator- iterator to traversebufferSize- 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 traversebufferSize- size of each read-ahead buffer. A larger size will increase both throughput and latency.bufferCount- number of read-ahead buffersthreadName- background thread name. A name will be automatically generated if this parameter is null.
-
-
Method Details
-
getThreadNamePrefix
-
close
public void close()Description copied from interface:CloseableIteratorShould be implemented to close/release any underlying resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableIterator<T>
-
hasNext
public boolean hasNext() -
next
-