Package jadex.commons.future
Interface IIntermediateFuture<E>
-
- All Superinterfaces:
IFuture<java.util.Collection<E>>
- All Known Subinterfaces:
IPullIntermediateFuture<E>
,IPullSubscriptionIntermediateFuture<E>
,ISubscriptionIntermediateFuture<E>
,ITerminableIntermediateFuture<E>
,ITuple2Future<E,F>
- All Known Implementing Classes:
IntermediateFuture
,PullIntermediateDelegationFuture
,PullIntermediateFuture
,PullSubscriptionIntermediateDelegationFuture
,PullSubscriptionIntermediateFuture
,SubscriptionIntermediateDelegationFuture
,SubscriptionIntermediateFuture
,TerminableIntermediateDelegationFuture
,TerminableIntermediateFuture
,Tuple2Future
public interface IIntermediateFuture<E> extends IFuture<java.util.Collection<E>>
Future that support intermediate results.
-
-
Field Summary
Fields Modifier and Type Field Description static IntermediateFuture<java.lang.Void>
DONE
A future representing a completed action.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener)
Add a functional result listener, which called on intermediate results.void
addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener, IFunctionalExceptionListener exceptionListener)
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)
Deprecated.Use addResultListener()<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 currently available.E
getNextIntermediateResult()
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.boolean
hasNextIntermediateResult(long timeout, boolean realtime)
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.-
Methods inherited from interface jadex.commons.future.IFuture
acceptEither, addResultListener, addResultListener, addResultListener, applyToEither, delegate, exceptionally, exceptionally, exceptionally, get, get, get, get, get, getException, isDone, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose
-
-
-
-
Field Detail
-
DONE
static final IntermediateFuture<java.lang.Void> DONE
A future representing a completed action. Can be used as direct return value of methods that do not perform asynchronous operations and do not return a result value.
-
-
Method Detail
-
getIntermediateResults
java.util.Collection<E> getIntermediateResults()
Get the intermediate results that are currently available. Non-blocking method.- Returns:
- The future result.
-
hasNextIntermediateResult
boolean hasNextIntermediateResult()
Check if there are more results for iteration for the given caller. If there are currently no unprocessed results and future is not yet finished, the caller is blocked until either new results are available and true is returned or the future is finished, thus returning false.- Returns:
- True, when there are more intermediate results for the caller.
-
hasNextIntermediateResult
boolean hasNextIntermediateResult(long timeout, boolean realtime)
Check if there are more results for iteration for the given caller. If there are currently no unprocessed results and future is not yet finished, the caller is blocked until either new results are available and true is returned or the future is finished, thus returning false.- Parameters:
timeout
- The timeout in millis.realtime
- Flag, if wait should be realtime (in constrast to simulation time).- Returns:
- True, when there are more intermediate results for the caller.
-
getNextIntermediateResult
E getNextIntermediateResult()
Iterate over the intermediate results in a blocking fashion. Manages results independently for different callers, i.e. when called from different threads, each thread receives all intermediate results. The operation is guaranteed to be non-blocking, if hasNextIntermediateResult() has returned true before for the same caller. Otherwise the caller is blocked until a result is available or the future is finished.- Returns:
- The next intermediate result.
-
getNextIntermediateResult
E getNextIntermediateResult(long timeout, boolean realtime)
Iterate over the intermediate results in a blocking fashion. Manages results independently for different callers, i.e. when called from different threads, each thread receives all intermediate results. The operation is guaranteed to be non-blocking, if hasNextIntermediateResult() has returned true before for the same caller. Otherwise the caller is blocked until a result is available or the future is finished.- Parameters:
timeout
- The timeout in millis.realtime
- Flag, if wait should be realtime (in constrast to simulation time).- Returns:
- The next intermediate result.
-
addIntermediateResultListener
void addIntermediateResultListener(IIntermediateResultListener<E> intermediateListener)
Deprecated.Use addResultListener()Add a result listener.- Parameters:
intermediateListener
- The intermediate listener.
-
addIntermediateResultListener
void addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener)
Add a functional result listener, which called on intermediate results. Exceptions will be logged.- Parameters:
intermediateListener
- The intermediate listener.
-
addIntermediateResultListener
void addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener, IFunctionalIntermediateFinishedListener<java.lang.Void> finishedListener)
Add a functional result listener, which called on intermediate results. Exceptions will be logged.- Parameters:
intermediateListener
- The intermediate listener.finishedListener
- The finished listener, called when no more intermediate results will arrive. Ifnull
, the finish event will be ignored.
-
addIntermediateResultListener
void addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener, IFunctionalExceptionListener exceptionListener)
Add a functional result listener, which called on intermediate results.- Parameters:
intermediateListener
- The intermediate listener.exceptionListener
- The listener that is called on exceptions. Passingnull
enables default exception logging.
-
addIntermediateResultListener
void addIntermediateResultListener(IFunctionalIntermediateResultListener<E> intermediateListener, IFunctionalIntermediateFinishedListener<java.lang.Void> finishedListener, IFunctionalExceptionListener exceptionListener)
Add a functional result listener, which called on intermediate results.- Parameters:
intermediateListener
- The intermediate listener.finishedListener
- The finished listener, called when no more intermediate results will arrive. Ifnull
, the finish event will be ignored.exceptionListener
- The listener that is called on exceptions. Passingnull
enables default exception logging.
-
mapAsync
<R> IIntermediateFuture<R> mapAsync(Function<E,IFuture<R>> function)
Implements async loop and applies a an async function to each element.- Parameters:
function
- The function.- Returns:
- True result intermediate future.
-
mapAsync
<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.- Parameters:
function
- The function.- Returns:
- True result intermediate future.
-
flatMapAsync
<R> IIntermediateFuture<R> flatMapAsync(Function<E,IIntermediateFuture<R>> function)
Implements async loop and applies a an async multi-function to each element.- Parameters:
function
- The function.- Returns:
- True result intermediate future.
-
-