public class IntermediateFuture<E> extends Future<java.util.Collection<E>> implements IIntermediateFuture<E>
IForwardCommandFuture.Type| Modifier and Type | Field and Description | 
|---|---|
protected java.util.Map<ISuspendable,java.lang.String> | 
icallers
The blocked intermediate callers (caller->state). 
 | 
protected java.util.Map<java.lang.Thread,java.lang.Integer> | 
indices
The index of the next result for a thread. 
 | 
protected boolean | 
intermediate
Flag indicating that addIntermediateResult()has been called. 
 | 
protected java.util.Collection<E> | 
results
The intermediate results. 
 | 
protected java.util.List | 
scheduled
The scheduled notifications. 
 | 
CALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, fcommands, first, listener, listeners, NO_STACK_COMPACTION, NONE, result, resultavailable, STACK, undone, UNSETDONE| Constructor and Description | 
|---|
IntermediateFuture()
Create a future that is already done. 
 | 
IntermediateFuture(java.util.Collection<E> results)
Create a future that is already done. 
 | 
IntermediateFuture(java.lang.Exception exception)
Create a future that is already done (failed). 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addIntermediateResult(E result)
Add an intermediate result. 
 | 
boolean | 
addIntermediateResultIfUndone(E result)
Set the result. 
 | 
void | 
addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener)
Add a functional result listener, which called on intermediate results. 
 | 
void | 
addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener,
                             IFunctionalIntermediateFinishedListener<java.lang.Void> finishedListener)
Add a functional result listener, which called on intermediate results. 
 | 
void | 
addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener,
                             IFunctionalIntermediateFinishedListener<java.lang.Void> finishedListener,
                             IFunctionalExceptionListener exceptionListener)
Add a functional result listener, which called on intermediate results. 
 | 
void | 
addIntermediateResultListener(IIntermediateResultListener<E> intermediateListener)
Add an result listener, which called on intermediate results. 
 | 
protected void | 
addResult(E result)
Add a result. 
 | 
void | 
addResultListener(IResultListener<java.util.Collection<E>> listener)
Add a result listener. 
 | 
protected boolean | 
doAddIntermediateResult(E result,
                       boolean undone)
Set the result without notifying listeners. 
 | 
protected E | 
doGetNextIntermediateResult(int index,
                           long timeout,
                           boolean realtime)
Perform the get without increasing the index. 
 | 
protected void | 
doNotifyListener(IResultListener<java.util.Collection<E>> listener)
Notify a result listener. 
 | 
protected boolean | 
doSetFinished(boolean undone)
Declare that the future is finished. 
 | 
protected boolean | 
doSetResult(java.util.Collection<E> result,
           boolean undone)
Set the result. 
 | 
<R> IIntermediateFuture<R> | 
flatMapAsync(Function<E,IIntermediateFuture<R>> function)
Implements async loop and applies a an async multi-function to each element. 
 | 
java.util.Collection<E> | 
getIntermediateResults()
Get the intermediate results that are available. 
 | 
E | 
getNextIntermediateResult()
Iterate over the intermediate results in a blocking fashion. 
 | 
E | 
getNextIntermediateResult(boolean realtime)
Iterate over the intermediate results in a blocking fashion. 
 | 
E | 
getNextIntermediateResult(long timeout,
                         boolean realtime)
Iterate over the intermediate results in a blocking fashion. 
 | 
boolean | 
hasNextIntermediateResult()
Check if there are more results for iteration for the given caller. 
 | 
<R> IIntermediateFuture<R> | 
mapAsync(Function<E,IFuture<R>> function)
Implements async loop and applies a an async function to each element. 
 | 
<R> IIntermediateFuture<R> | 
mapAsync(Function<E,IFuture<R>> function,
        java.lang.Class<?> futuretype)
Implements async loop and applies a an async function to each element. 
 | 
protected void | 
notifyIntermediateResult(IIntermediateResultListener<E> listener,
                        E result)
Notify a result listener. 
 | 
protected void | 
notifyListener(IResultListener<java.util.Collection<E>> listener)
Notify a result listener. 
 | 
protected void | 
resume()
Resume also intermediate waiters. 
 | 
protected void | 
resumeIntermediate()
Resume after intermediate result. 
 | 
protected void | 
scheduleNotification(IResultListener<java.util.Collection<E>> listener,
                    boolean intermediate,
                    java.lang.Object result)
Schedule a listener notification. 
 | 
void | 
setFinished()
Declare that the future is finished. 
 | 
boolean | 
setFinishedIfUndone()
Declare that the future is finished. 
 | 
protected void | 
startScheduledNotifications()
Start scheduled listener notifications if not already running. 
 | 
abortGet, acceptEither, addForwardCommand, addResultListener, addResultListener, applyToEither, doSetException, get, get, get, get, get, getEmptyFuture, getException, getFuture, hasResultListener, isDone, notifyListenerCommand, removeForwardCommand, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenComposeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitacceptEither, addResultListener, addResultListener, applyToEither, get, get, get, get, get, getException, isDone, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenComposeprotected java.util.Collection<E> results
protected boolean intermediate
protected java.util.List scheduled
protected java.util.Map<ISuspendable,java.lang.String> icallers
protected java.util.Map<java.lang.Thread,java.lang.Integer> indices
public IntermediateFuture()
result - The result, if any.public IntermediateFuture(java.util.Collection<E> results)
result - The result, if any.public IntermediateFuture(java.lang.Exception exception)
exception - The exception.public java.util.Collection<E> getIntermediateResults()
getIntermediateResults in interface IIntermediateFuture<E>public void addIntermediateResult(E result)
public boolean addIntermediateResultIfUndone(E result)
result - The result.protected boolean doAddIntermediateResult(E result, boolean undone)
protected void addResult(E result)
result - The result.protected boolean doSetResult(java.util.Collection<E> result, boolean undone)
doSetResult in class Future<java.util.Collection<E>>result - The result.public void setFinished()
public boolean setFinishedIfUndone()
protected boolean doSetFinished(boolean undone)
public void addResultListener(IResultListener<java.util.Collection<E>> listener)
addResultListener in interface IFuture<java.util.Collection<E>>addResultListener in class Future<java.util.Collection<E>>listener - The listener.public void addIntermediateResultListener(IIntermediateResultListener<E> intermediateListener)
addIntermediateResultListener in interface IIntermediateFuture<E>intermediateListener - The intermediate listener.public void addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener)
addIntermediateResultListener in interface IIntermediateFuture<E>intermediateListener - The intermediate listener.public void addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener, IFunctionalIntermediateFinishedListener<java.lang.Void> finishedListener)
addIntermediateResultListener in interface IIntermediateFuture<E>intermediateListener - The intermediate listener.finishedListener - The finished listener, called when no more
        intermediate results will arrive. If null, the finish
        event will be ignored.public void addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener, IFunctionalIntermediateFinishedListener<java.lang.Void> finishedListener, IFunctionalExceptionListener exceptionListener)
addIntermediateResultListener in interface IIntermediateFuture<E>intermediateListener - The intermediate listener.finishedListener - The finished listener, called when no more
        intermediate results will arrive. If null, the finish
        event will be ignored.exceptionListener - The listener that is called on exceptions. Passing
        null enables default exception logging.public boolean hasNextIntermediateResult()
hasNextIntermediateResult in interface IIntermediateFuture<E>public E getNextIntermediateResult()
getNextIntermediateResult in interface IIntermediateFuture<E>NoSuchElementException, - when there are no more intermediate results and the future is finished.public E getNextIntermediateResult(boolean realtime)
NoSuchElementException, - when there are no more intermediate results and the future is finished.public E getNextIntermediateResult(long timeout, boolean realtime)
NoSuchElementException, - when there are no more intermediate results and the future is finished.protected E doGetNextIntermediateResult(int index, long timeout, boolean realtime)
protected void notifyIntermediateResult(IIntermediateResultListener<E> listener, E result)
listener - The listener.protected void notifyListener(IResultListener<java.util.Collection<E>> listener)
notifyListener in class Future<java.util.Collection<E>>listener - The listener.protected void doNotifyListener(IResultListener<java.util.Collection<E>> listener)
listener - The listener.protected void scheduleNotification(IResultListener<java.util.Collection<E>> listener, boolean intermediate, java.lang.Object result)
listener - The listener to be notified.intermediate - True for intermediate result, false for final results.result - The intermediate result (if any).protected void startScheduledNotifications()
protected void resume()
protected void resumeIntermediate()
public <R> IIntermediateFuture<R> mapAsync(Function<E,IFuture<R>> function)
mapAsync in interface IIntermediateFuture<E>function - The function.public <R> IIntermediateFuture<R> mapAsync(Function<E,IFuture<R>> function, java.lang.Class<?> futuretype)
mapAsync in interface IIntermediateFuture<E>function - The function.public <R> IIntermediateFuture<R> flatMapAsync(Function<E,IIntermediateFuture<R>> function)
flatMapAsync in interface IIntermediateFuture<E>function - The function.