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 java.util.stream.Stream<E>
asStream()
Return a stream of the results of this future.java.util.stream.Stream<E>
asStream(long timeout, boolean realtime)
Return a stream of the results of this future.IIntermediateFuture<? extends E>
done(java.util.function.Consumer<? super java.lang.Exception> function)
Called when the future is done (finished or exception occurred).IIntermediateFuture<? extends E>
finished(java.util.function.Consumer<java.lang.Void> function)
Called when the future is finished.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.IIntermediateFuture<? extends E>
max(java.util.function.Consumer<java.lang.Integer> function)
Called when the maximum number of results is available.IIntermediateFuture<? extends E>
next(java.util.function.Consumer<? super E> function)
Deprecated.-
Methods inherited from interface jadex.commons.future.IFuture
addResultListener, catchEx, catchEx, catchEx, delegate, get, get, get, get, get, getException, isDone, then, thenApply, thenApply, 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.
-
next
IIntermediateFuture<? extends E> next(java.util.function.Consumer<? super E> function)
Deprecated.Called when the next intermediate value is available.- Parameters:
function
- Called when value arrives.- Returns:
- The future for chaining.
-
max
IIntermediateFuture<? extends E> max(java.util.function.Consumer<java.lang.Integer> function)
Called when the maximum number of results is available.- Parameters:
function
- Called when max value arrives.- Returns:
- The future for chaining.
-
finished
IIntermediateFuture<? extends E> finished(java.util.function.Consumer<java.lang.Void> function)
Called when the future is finished.- Parameters:
function
- Called when max value arrives.- Returns:
- The future for chaining.
-
done
IIntermediateFuture<? extends E> done(java.util.function.Consumer<? super java.lang.Exception> function)
Called when the future is done (finished or exception occurred). Exception parameter will be set if the cause was an exception, null otherwise.- Parameters:
function
- Called future is done.- Returns:
- The future for chaining.
-
asStream
java.util.stream.Stream<E> asStream()
Return a stream of the results of this future. Although this method itself is non-blocking, all terminal stream methods (e.g. forEach) will block until the future is finished!
-
asStream
java.util.stream.Stream<E> asStream(long timeout, boolean realtime)
Return a stream of the results of this future. Use the given timeout settings when waiting for elements in the stream. Although this method itself is non-blocking, all terminal stream methods (e.g. forEach) will block until the future is finished!- Parameters:
timeout
- The timeout in millis.realtime
- Flag, if wait should be realtime (in constrast to simulation time).
-
-