Package jadex.future
Class Tuple2Future<E,F>
- All Implemented Interfaces:
IForwardCommandFuture,IFuture<Collection<TupleResult>>,IIntermediateFuture<TupleResult>,ITuple2Future<E,,F> Supplier<Collection<TupleResult>>
public class Tuple2Future<E,F>
extends IntermediateFuture<TupleResult>
implements ITuple2Future<E,F>
Implementation of tuple2 future.
The future is considered as finished when all tuple elements have been set.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jadex.future.IForwardCommandFuture
IForwardCommandFuture.Type -
Field Summary
Fields inherited from class jadex.future.IntermediateFuture
icallers, indices, intermediate, maxresultcnt, notcommand, resultsFields inherited from class jadex.future.Future
CALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, first, listeners, NO_STACK_COMPACTION, NONE, NOTIFICATIONS, notificount, notified, result, resultavailable, undone, UNSETFields inherited from interface jadex.future.IIntermediateFuture
DONE -
Constructor Summary
ConstructorsConstructorDescriptionCreate a future that is already done.Tuple2Future(E result1, F result2) Create a future that is already done.Tuple2Future(Exception exception) Create a future that is already done (failed). -
Method Summary
Modifier and TypeMethodDescriptionprotected TupleResultfindResult(int idx) Find result in resultsGet the first result.getFirstResult(long timeout) Get the first result.getFirstResult(long timeout, boolean realtime) Get the first result.Deprecated.- From 3.0.protected intgetMax()Get the number of results of the type of future..Get the second result.getSecondResult(long timeout) Get the second result.getSecondResult(long timeout, boolean realtime) Get the second result.protected ObjectgetXResult(int idx, long timeout, boolean realtime) Get the x result.protected voidnotifyIntermediateResult(IIntermediateResultListener<TupleResult> listener, TupleResult result) Notify a result listener.voidsetFirstResult(E result) Set the result.voidsetFirstResultIfUndone(E result) Set the result.voidsetSecondResult(F result) Set the result.voidsetSecondResultIfUndone(F result) Set the result.protected voidsetXResult(int idx, Object res) Set the xth result.protected voidsetXResultIfUndone(int idx, Object res) Set the xth result.Methods inherited from class jadex.future.IntermediateFuture
addIntermediateResult, addIntermediateResultIfUndone, addResultListener, asStream, asStream, catchEx, delegateEx, delegateFrom, doAddIntermediateResult, doGetNextIntermediateResult, done, doSetException, doSetFinished, doSetResult, finished, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, getNextIntermediateResult, getNotificationCommand, getResultCount, hasNextIntermediateResult, hasNextIntermediateResult, max, next, resume, resumeIntermediate, scheduleMaxNotification, setFinished, setFinishedIfUndone, setMaxResultCount, storeResult, thenMethods inherited from class jadex.future.Future
abortGet, catchEx, catchEx, delegate, delegateTo, doAddResultListener, doStartScheduledNotifications, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, hasResultListener, isDone, isNotified, printOnEx, scheduleNotification, scheduleNotification, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, startScheduledNotifications, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose, throwExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jadex.future.IFuture
addResultListener, catchEx, catchEx, catchEx, delegate, delegateTo, get, get, get, get, get, getException, isDone, printOnEx, then, thenApply, thenApply, thenCompose, thenComposeMethods inherited from interface jadex.future.IIntermediateFuture
asStream, asStream, done, finished, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, hasNextIntermediateResult, hasNextIntermediateResult, max, next
-
Constructor Details
-
Tuple2Future
public Tuple2Future()Create a future that is already done. -
Tuple2Future
Create a future that is already done.- Parameters:
result1- The first result.result2- The second result.
-
Tuple2Future
Create a future that is already done (failed).- Parameters:
exception- The exception.
-
-
Method Details
-
getFirstResult
Deprecated.- From 3.0. Use method without suspendable. Will NOT use the suspendable that is supplied as parameter. Get the first result.- Specified by:
getFirstResultin interfaceITuple2Future<E,F> - Returns:
- The next intermediate result.
- Throws:
NoSuchElementException- when there are no more intermediate results and the future is finished.
-
getFirstResult
Get the first result.- Specified by:
getFirstResultin interfaceITuple2Future<E,F> - Returns:
- The next intermediate result.
- Throws:
NoSuchElementException- when there are no more intermediate results and the future is finished.
-
getSecondResult
Get the second result.- Specified by:
getSecondResultin interfaceITuple2Future<E,F> - Returns:
- The next intermediate result.
- Throws:
NoSuchElementException- when there are no more intermediate results and the future is finished.
-
getFirstResult
Get the first result.- Specified by:
getFirstResultin interfaceITuple2Future<E,F> - Parameters:
timeout- The timeout in millis.- Returns:
- The next intermediate result.
- Throws:
NoSuchElementException- when there are no more intermediate results and the future is finished.
-
getSecondResult
Get the second result.- Specified by:
getSecondResultin interfaceITuple2Future<E,F> - Parameters:
timeout- The timeout in millis.- Returns:
- The next intermediate result.
- Throws:
NoSuchElementException- when there are no more intermediate results and the future is finished.
-
getFirstResult
Get the first result.- Specified by:
getFirstResultin interfaceITuple2Future<E,F> - Parameters:
timeout- The timeout in millis.realtime- Flag if wait should be realtime (in contrast to simulation time).- Returns:
- The next intermediate result.
- Throws:
NoSuchElementException- when there are no more intermediate results and the future is finished.
-
getSecondResult
Get the second result.- Specified by:
getSecondResultin interfaceITuple2Future<E,F> - Parameters:
timeout- The timeout in millis.realtime- Flag if wait should be realtime (in contrast to simulation time).- Returns:
- The next intermediate result.
- Throws:
NoSuchElementException- when there are no more intermediate results and the future is finished.
-
setFirstResult
Set the result. Listener notifications occur on calling thread of this method.- Parameters:
result- The result.
-
setSecondResult
Set the result. Listener notifications occur on calling thread of this method.- Parameters:
result- The result.
-
setFirstResultIfUndone
Set the result. Listener notifications occur on calling thread of this method.- Parameters:
result- The result.
-
setSecondResultIfUndone
Set the result. Listener notifications occur on calling thread of this method.- Parameters:
result- The result.
-
setXResult
Set the xth result. -
setXResultIfUndone
Set the xth result. -
getXResult
Get the x result.- Returns:
- The next intermediate result.
- Throws:
NoSuchElementException- when there are no more intermediate results and the future is finished.
-
findResult
Find result in results -
getMax
protected int getMax()Get the number of results of the type of future.. -
notifyIntermediateResult
protected void notifyIntermediateResult(IIntermediateResultListener<TupleResult> listener, TupleResult result) Notify a result listener.- Overrides:
notifyIntermediateResultin classIntermediateFuture<TupleResult>- Parameters:
listener- The listener.
-