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, results
Fields 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, UNSET
Fields 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 TupleResult
findResult
(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 int
getMax()
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 Object
getXResult
(int idx, long timeout, boolean realtime) Get the x result.protected void
notifyIntermediateResult
(IIntermediateResultListener<TupleResult> listener, TupleResult result) Notify a result listener.void
setFirstResult
(E result) Set the result.void
setFirstResultIfUndone
(E result) Set the result.void
setSecondResult
(F result) Set the result.void
setSecondResultIfUndone
(F result) Set the result.protected void
setXResult
(int idx, Object res) Set the xth result.protected void
setXResultIfUndone
(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, then
Methods 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, throwException
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jadex.future.IFuture
addResultListener, catchEx, catchEx, catchEx, delegate, delegateTo, get, get, get, get, get, getException, isDone, printOnEx, then, thenApply, thenApply, thenCompose, thenCompose
Methods 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:
getFirstResult
in 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:
getFirstResult
in 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:
getSecondResult
in 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:
getFirstResult
in 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:
getSecondResult
in 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:
getFirstResult
in 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:
getSecondResult
in 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:
notifyIntermediateResult
in classIntermediateFuture<TupleResult>
- Parameters:
listener
- The listener.
-