public abstract class BlockingHandoff<T>
extends java.lang.Object
implements java.lang.Iterable<T>, java.lang.AutoCloseable
| Constructor and Description |
|---|
BlockingHandoff(T endSentinel,
long timeoutMs)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected abstract void |
itemTimeout(long timeoutMs)
Inform the derived class that we timed-out while waiting for an item
This function must not return (i.e., you must throw an exception)
|
java.util.Iterator<T> |
iterator() |
protected abstract void |
iteratorTimeout() |
boolean |
put(T item)
Put an item into the handoff for consumption.
|
void |
putEos()
Indicate that there are no more items.
|
void |
putException(java.lang.Exception ex) |
protected abstract void |
setup(java.util.concurrent.CountDownLatch readyLatch) |
protected void |
throwQueryTimeout()
Throw a QueryTimeoutException.
|
public BlockingHandoff(T endSentinel, long timeoutMs)
timeoutMs - the maximum amount of time that can pass when waiting
for an item from the iterator.protected void throwQueryTimeout()
protected abstract void itemTimeout(long timeoutMs)
timeoutMs - how long the timeout waspublic boolean put(T item)
item - the new itempublic void putException(java.lang.Exception ex)
public void putEos()
protected abstract void setup(java.util.concurrent.CountDownLatch readyLatch)
protected abstract void iteratorTimeout()
public java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>public void close()
close in interface java.lang.AutoCloseable