Package jadex.commons.future
Class Tuple2Future<E,F>
- java.lang.Object
-
- jadex.commons.future.Future<java.util.Collection<E>>
-
- jadex.commons.future.IntermediateFuture<TupleResult>
-
- jadex.commons.future.Tuple2Future<E,F>
-
- All Implemented Interfaces:
IForwardCommandFuture
,IFuture<java.util.Collection<TupleResult>>
,IIntermediateFuture<TupleResult>
,ITuple2Future<E,F>
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.commons.future.IForwardCommandFuture
IForwardCommandFuture.Type
-
-
Field Summary
-
Fields inherited from class jadex.commons.future.IntermediateFuture
icallers, indices, intermediate, maxresultcnt, notcommand, results
-
Fields inherited from class jadex.commons.future.Future
CALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, first, listener, listeners, NO_STACK_COMPACTION, NONE, notifications, result, resultavailable, STACK, undone, UNSET
-
Fields inherited from interface jadex.commons.future.IIntermediateFuture
DONE
-
-
Constructor Summary
Constructors Constructor Description Tuple2Future()
Create a future that is already done.Tuple2Future(E result1, F result2)
Create a future that is already done.Tuple2Future(java.lang.Exception exception)
Create a future that is already done (failed).
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected TupleResult
findResult(int idx)
Find result in resultsE
getFirstResult()
Get the first result.E
getFirstResult(long timeout)
Get the first result.E
getFirstResult(long timeout, boolean realtime)
Get the first result.E
getFirstResult(ThreadSuspendable sus)
Deprecated.- From 3.0.protected int
getMax()
Get the number of results of the type of future..F
getSecondResult()
Get the second result.F
getSecondResult(long timeout)
Get the second result.F
getSecondResult(long timeout, boolean realtime)
Get the second result.protected java.lang.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, java.lang.Object res)
Set the xth result.protected void
setXResultIfUndone(int idx, java.lang.Object res)
Set the xth result.-
Methods inherited from class jadex.commons.future.IntermediateFuture
addIntermediateResult, addIntermediateResultIfUndone, addIntermediateResultListener, addResultListener, catchErr, doAddIntermediateResult, doGetNextIntermediateResult, doSetFinished, doSetResult, finished, flatMapAsync, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, getNextIntermediateResult, getNotificationCommand, getResultCount, hasNextIntermediateResult, hasNextIntermediateResult, mapAsync, mapAsync, max, next, resume, resumeIntermediate, scheduleMaxNotification, setFinished, setFinishedIfUndone, setMaxResultCount, storeResult
-
Methods inherited from class jadex.commons.future.Future
abortGet, catchErr, catchErr, delegate, doSetException, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, hasResultListener, isDone, notifyListener, notifyListener, scheduleNotification, scheduleNotification, scheduleNotification, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, startScheduledNotifications, then, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jadex.commons.future.IFuture
addResultListener, catchErr, catchErr, catchErr, delegate, get, get, get, get, get, getException, isDone, then, thenApply, thenApply, thenCompose, thenCompose
-
Methods inherited from interface jadex.commons.future.IIntermediateFuture
finished, flatMapAsync, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, hasNextIntermediateResult, hasNextIntermediateResult, mapAsync, mapAsync, max, next
-
-
-
-
Constructor Detail
-
Tuple2Future
public Tuple2Future()
Create a future that is already done.- Parameters:
result
- The result, if any.
-
Tuple2Future
public Tuple2Future(E result1, F result2)
Create a future that is already done.- Parameters:
result
- The result, if any.
-
Tuple2Future
public Tuple2Future(java.lang.Exception exception)
Create a future that is already done (failed).- Parameters:
exception
- The exception.
-
-
Method Detail
-
getFirstResult
public E getFirstResult(ThreadSuspendable sus)
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.
-
getFirstResult
public E getFirstResult()
Get the first result.- Specified by:
getFirstResult
in interfaceITuple2Future<E,F>
- Returns:
- The next intermediate result.
-
getSecondResult
public F getSecondResult()
Get the second result.- Specified by:
getSecondResult
in interfaceITuple2Future<E,F>
- Returns:
- The next intermediate result.
-
getFirstResult
public E getFirstResult(long timeout)
Get the first result.- Specified by:
getFirstResult
in interfaceITuple2Future<E,F>
- Parameters:
timeout
- The timeout in millis.- Returns:
- The next intermediate result.
-
getSecondResult
public F getSecondResult(long timeout)
Get the second result.- Specified by:
getSecondResult
in interfaceITuple2Future<E,F>
- Parameters:
timeout
- The timeout in millis.- Returns:
- The next intermediate result.
-
getFirstResult
public E getFirstResult(long timeout, boolean realtime)
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.
-
getSecondResult
public F getSecondResult(long timeout, boolean realtime)
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.
-
setFirstResult
public void setFirstResult(E result)
Set the result. Listener notifications occur on calling thread of this method.- Parameters:
result
- The result.
-
setSecondResult
public void setSecondResult(F result)
Set the result. Listener notifications occur on calling thread of this method.- Parameters:
result
- The result.
-
setFirstResultIfUndone
public void setFirstResultIfUndone(E result)
Set the result. Listener notifications occur on calling thread of this method.- Parameters:
result
- The result.
-
setSecondResultIfUndone
public void setSecondResultIfUndone(F result)
Set the result. Listener notifications occur on calling thread of this method.- Parameters:
result
- The result.
-
setXResult
protected void setXResult(int idx, java.lang.Object res)
Set the xth result.
-
setXResultIfUndone
protected void setXResultIfUndone(int idx, java.lang.Object res)
Set the xth result.
-
getXResult
protected java.lang.Object getXResult(int idx, long timeout, boolean realtime)
Get the x result.- Returns:
- The next intermediate result.
-
findResult
protected TupleResult findResult(int idx)
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.
-
-