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.
  • Constructor Details

    • Tuple2Future

      public Tuple2Future()
      Create a future that is already done.
    • Tuple2Future

      public Tuple2Future(E result1, F result2)
      Create a future that is already done.
      Parameters:
      result1 - The first result.
      result2 - The second result.
    • Tuple2Future

      public Tuple2Future(Exception exception)
      Create a future that is already done (failed).
      Parameters:
      exception - The exception.
  • Method Details

    • 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 interface ITuple2Future<E,F>
      Returns:
      The next intermediate result.
      Throws:
      NoSuchElementException - when there are no more intermediate results and the future is finished.
    • getFirstResult

      public E getFirstResult()
      Get the first result.
      Specified by:
      getFirstResult in interface ITuple2Future<E,F>
      Returns:
      The next intermediate result.
      Throws:
      NoSuchElementException - when there are no more intermediate results and the future is finished.
    • getSecondResult

      public F getSecondResult()
      Get the second result.
      Specified by:
      getSecondResult in interface ITuple2Future<E,F>
      Returns:
      The next intermediate result.
      Throws:
      NoSuchElementException - when there are no more intermediate results and the future is finished.
    • getFirstResult

      public E getFirstResult(long timeout)
      Get the first result.
      Specified by:
      getFirstResult in interface ITuple2Future<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

      public F getSecondResult(long timeout)
      Get the second result.
      Specified by:
      getSecondResult in interface ITuple2Future<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

      public E getFirstResult(long timeout, boolean realtime)
      Get the first result.
      Specified by:
      getFirstResult in interface ITuple2Future<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

      public F getSecondResult(long timeout, boolean realtime)
      Get the second result.
      Specified by:
      getSecondResult in interface ITuple2Future<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

      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, Object res)
      Set the xth result.
    • setXResultIfUndone

      protected void setXResultIfUndone(int idx, Object res)
      Set the xth result.
    • getXResult

      protected Object getXResult(int idx, long timeout, boolean realtime)
      Get the x result.
      Returns:
      The next intermediate result.
      Throws:
      NoSuchElementException - when there are no more intermediate results and the future is finished.
    • 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 class IntermediateFuture<TupleResult>
      Parameters:
      listener - The listener.