Class MarkableSequenceInputStream.FetchingListIterator<E>

java.lang.Object
org.postgresql.pljava.internal.MarkableSequenceInputStream.FetchingListIterator<E>
All Implemented Interfaces:
Iterator<E>, ListIterator<E>
Enclosing class:
MarkableSequenceInputStream

public static class MarkableSequenceInputStream.FetchingListIterator<E> extends Object implements ListIterator<E>
A ListIterator that will fetch an element from a BlockingQueue whenever hasNext would (otherwise) return false, adding it to the end of the list where the next next() will retrieve it.

It is possible for the hasNext, next, and nextIndex methods to throw CancellationException, if the thread is interrupted while they await something on the queue.

  • Constructor Details

    • FetchingListIterator

      public FetchingListIterator(List<E> list, BlockingQueue<E> queue, E sentinel)
      Construct a FetchingListIterator given an existing list, a BlockingQueue, and a particular instance of the list's element type to use as an end-of-queue sentinel (it is not possible to enqueue a null value on a BlockingQueue).
      Parameters:
      list - An existing list.
      queue - A blocking queue whose elements will be taken in order following any existing elements in the original list.
      sentinel - A value that the supplier, feeding the blocking queue, will enqueue when no more actual values will be forthcoming. When an element is dequeued that matches this sentinel (per reference equality), it is not added to the list, and nothing more will be fetched from the queue.
      Throws:
      NullPointerException - if any parameter is null.
  • Method Details