Package jadex.bridge

Class SFuture


  • public class SFuture
    extends java.lang.Object
    Helper class for future aspects.
    • Constructor Summary

      Constructors 
      Constructor Description
      SFuture()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret, IExternalAccess ea)
      Automatically update the timer of a long running service call future.
      static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret, IExternalAccess ea, long to, boolean realtime)
      Automatically update the timer of a long running service call future.
      static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret, IExternalAccess ea, long to, double factor, boolean realtime)
      Automatically update the timer of a long running service call future.
      static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret, IInternalAccess ia)
      Automatically update the timer of a long running service call future.
      static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret, IInternalAccess ia, boolean realtime)
      Automatically update the timer of a long running service call future.
      static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret, IInternalAccess ia, long to, boolean realtime)
      Automatically update the timer of a long running service call future.
      static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret, IInternalAccess ia, long to, double factor, boolean realtime)
      Automatically update the timer of a long running service call future.
      static <T,​E>
      jadex.commons.future.ISubscriptionIntermediateFuture<T>
      combineSubscriptionFutures​(IInternalAccess ia, jadex.commons.future.ISubscriptionIntermediateFuture<E> f1, jadex.commons.future.ISubscriptionIntermediateFuture<E> f2, jadex.commons.IResultCommand<T,​E> cmd, jadex.commons.ICommand<java.lang.Exception> termcom)
      Combine results of two subscription futures and exclude duplicates (uses sliding cuckoo filter with toString() on results).
      static <T> jadex.commons.future.ISubscriptionIntermediateFuture<T> combineSubscriptionFutures​(IInternalAccess ia, jadex.commons.future.ISubscriptionIntermediateFuture<T> f1, jadex.commons.future.ISubscriptionIntermediateFuture<T> f2)
      Combine results of two subscription futures and exclude duplicates (uses sliding cuckoo filter with toString() on results).
      static <T> T getFirstResultAndTerminate​(jadex.commons.future.ITerminableIntermediateFuture<T> fut)
      Blocking wait for first result.
      static <T> jadex.commons.future.Future<?> getFuture​(boolean timeouts, IInternalAccess ia)
      Convenience method for creating a future (possibly with timeout avoidance).
      static jadex.commons.future.Future<?> getFuture​(java.lang.Class<?> clazz)
      Get the matching future object to a future (interface) type.
      static <T> jadex.commons.future.Future<?> getFuture​(java.lang.Class<T> type, boolean timeouts, IExternalAccess ea)
      Convenience method for creating a future (possibly with timeout avoidance).
      static <T> jadex.commons.future.Future<?> getFuture​(java.lang.Class<T> type, boolean timeouts, IInternalAccess ia)
      Convenience method for creating a future (possibly with timeout avoidance).
      static <T> jadex.commons.future.Future<?> getNoTimeoutFuture​(IInternalAccess ia)
      Convenience method for creating a future (possibly with timeout avoidance).
      static <T> jadex.commons.future.Future<?> getNoTimeoutFuture​(java.lang.Class<T> type, IExternalAccess ea)
      Convenience method for creating a future (possibly with timeout avoidance).
      static <T> jadex.commons.future.Future<?> getNoTimeoutFuture​(java.lang.Class<T> type, IInternalAccess ia)
      Convenience method for creating a future (possibly with timeout avoidance).
      static <T> jadex.commons.future.Future<?> getNoTimeoutFuture​(java.lang.Class<T> type, IInternalAccess ia, boolean realtime)
      Convenience method for creating a future with timeout avoidance.
      static <T> jadex.commons.future.IntermediateFuture<T> streamToFuture​(IInternalAccess agent, java.util.stream.Stream<T> results)
      Create an intermediate future for a stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SFuture

        public SFuture()
    • Method Detail

      • streamToFuture

        public static <T> jadex.commons.future.IntermediateFuture<T> streamToFuture​(IInternalAccess agent,
                                                                                    java.util.stream.Stream<T> results)
        Create an intermediate future for a stream. The results are pulled from the stream using the agent thread i.e. the agent will be blocked when waiting for stream results. Safe to use (but somewhat useless) for finished streams. Also safe to use for streams, created with IntermediateFuture.asStream(). Not safe to use for other kinds of infinite streams!
      • avoidCallTimeouts

        public static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret,
                                             IInternalAccess ia)
        Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that time span. The call periodically sends alive calls to the caller.
        Parameters:
        ret - The future that is returned by the service call.
        ia - The component handling the service call (on that component the periodic updates are scheduled).
      • avoidCallTimeouts

        public static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret,
                                             IInternalAccess ia,
                                             boolean realtime)
        Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that time span. The call periodically sends alive calls to the caller.
        Parameters:
        ret - The future that is returned by the service call.
        ia - The component handling the service call (on that component the periodic updates are scheduled).
        realtime - true, for real time timeouts (simulation clock based timeouts otherwise).
      • avoidCallTimeouts

        public static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret,
                                             IExternalAccess ea)
        Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.
        Parameters:
        ret - The future that is returned by the service call.
        ea - The component handling the service call (on that component the periodic updates are scheduled).
      • avoidCallTimeouts

        public static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret,
                                             IInternalAccess ia,
                                             long to,
                                             boolean realtime)
        Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.
        Parameters:
        ret - The future that is returned by the service call.
        ia - The component handling the service call (on that component the periodic updates are scheduled).
        to - The timeout.
      • avoidCallTimeouts

        public static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret,
                                             IExternalAccess ea,
                                             long to,
                                             boolean realtime)
        Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.
        Parameters:
        ret - The future that is returned by the service call.
        ea - The component handling the service call (on that component the periodic updates are scheduled).
        to - The timeout.
      • avoidCallTimeouts

        public static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret,
                                             IInternalAccess ia,
                                             long to,
                                             double factor,
                                             boolean realtime)
        Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.
        Parameters:
        ret - The future that is returned by the service call.
        ia - The component handling the service call (on that component the periodic updates are scheduled).
        to - The timeout.
        factor - (default 0.8) Used to update the timer when factor*to has elapsed.
      • avoidCallTimeouts

        public static void avoidCallTimeouts​(jadex.commons.future.Future<?> ret,
                                             IExternalAccess ea,
                                             long to,
                                             double factor,
                                             boolean realtime)
        Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.
        Parameters:
        ret - The future that is returned by the service call.
        ea - The component handling the service call (on that component the periodic updates are scheduled).
        to - The timeout.
        factor - (default 0.8) Used to update the timer when factor*to has elapsed.
      • getNoTimeoutFuture

        public static <T> jadex.commons.future.Future<?> getNoTimeoutFuture​(IInternalAccess ia)
        Convenience method for creating a future (possibly with timeout avoidance).
        Parameters:
        timeouts - (default is true) False, if no timeouts should be generated when service call timeout has elapsed.
        ea - The external access.
      • getNoTimeoutFuture

        public static <T> jadex.commons.future.Future<?> getNoTimeoutFuture​(java.lang.Class<T> type,
                                                                            IInternalAccess ia)
        Convenience method for creating a future (possibly with timeout avoidance).
        Parameters:
        timeouts - (default is true) False, if no timeouts should be generated when service call timeout has elapsed.
        ia - The internal access.
      • getNoTimeoutFuture

        public static <T> jadex.commons.future.Future<?> getNoTimeoutFuture​(java.lang.Class<T> type,
                                                                            IInternalAccess ia,
                                                                            boolean realtime)
        Convenience method for creating a future with timeout avoidance.
        Parameters:
        type - The future type (e.g. IntermediateFuture.class).
        ia - The internal access.
        realtime - true, for real time timeouts (simulation clock based timeouts otherwise).
      • getNoTimeoutFuture

        public static <T> jadex.commons.future.Future<?> getNoTimeoutFuture​(java.lang.Class<T> type,
                                                                            IExternalAccess ea)
        Convenience method for creating a future (possibly with timeout avoidance).
        Parameters:
        timeouts - (default is true) False, if no timeouts should be generated when service call timeout has elapsed.
        ea - The external access.
      • getFuture

        public static <T> jadex.commons.future.Future<?> getFuture​(boolean timeouts,
                                                                   IInternalAccess ia)
        Convenience method for creating a future (possibly with timeout avoidance).
        Parameters:
        timeouts - (default is true) False, if no timeouts should be generated when service call timeout has elapsed.
        ia - The external access.
      • getFuture

        public static <T> jadex.commons.future.Future<?> getFuture​(java.lang.Class<T> type,
                                                                   boolean timeouts,
                                                                   IInternalAccess ia)
        Convenience method for creating a future (possibly with timeout avoidance).
        Parameters:
        type - The future implementation type.
        timeouts - (default is true) False, if no timeouts should be generated when service call timeout has elapsed.
        ia - The external access.
      • getFuture

        public static <T> jadex.commons.future.Future<?> getFuture​(java.lang.Class<T> type,
                                                                   boolean timeouts,
                                                                   IExternalAccess ea)
        Convenience method for creating a future (possibly with timeout avoidance).
        Parameters:
        type - The future implementation type.
        timeouts - (default is true) False, if no timeouts should be generated when service call timeout has elapsed.
        ea - The external access.
      • getFuture

        public static jadex.commons.future.Future<?> getFuture​(java.lang.Class<?> clazz)
        Get the matching future object to a future (interface) type.
      • getFirstResultAndTerminate

        public static <T> T getFirstResultAndTerminate​(jadex.commons.future.ITerminableIntermediateFuture<T> fut)
        Blocking wait for first result. Future is terminated after first result is received. Defaults to realtime timeout (hack?)
        Parameters:
        fut - The future.
        Returns:
        The first result.
      • combineSubscriptionFutures

        public static <T> jadex.commons.future.ISubscriptionIntermediateFuture<T> combineSubscriptionFutures​(IInternalAccess ia,
                                                                                                             jadex.commons.future.ISubscriptionIntermediateFuture<T> f1,
                                                                                                             jadex.commons.future.ISubscriptionIntermediateFuture<T> f2)
        Combine results of two subscription futures and exclude duplicates (uses sliding cuckoo filter with toString() on results).
        Parameters:
        f1 - Future 1.
        f2 - Future 2.
        Returns:
        A future combining results of f1 and f2.
      • combineSubscriptionFutures

        public static <T,​E> jadex.commons.future.ISubscriptionIntermediateFuture<T> combineSubscriptionFutures​(IInternalAccess ia,
                                                                                                                     jadex.commons.future.ISubscriptionIntermediateFuture<E> f1,
                                                                                                                     jadex.commons.future.ISubscriptionIntermediateFuture<E> f2,
                                                                                                                     jadex.commons.IResultCommand<T,​E> cmd,
                                                                                                                     jadex.commons.ICommand<java.lang.Exception> termcom)
        Combine results of two subscription futures and exclude duplicates (uses sliding cuckoo filter with toString() on results).
        Parameters:
        f1 - Future 1.
        f2 - Future 2.
        Returns:
        A future combining results of f1 and f2.