Interface IFuture<E>

    • Field Detail

      • DONE

        static final IFuture<java.lang.Void> DONE
        A future representing a completed action. Can be used as direct return value of methods that do not perform asynchronous operations and do not return a result value.
      • TRUE

        static final IFuture<java.lang.Boolean> TRUE
        A future representing a true result.
      • FALSE

        static final IFuture<java.lang.Boolean> FALSE
        A future representing a false result.
    • Method Detail

      • isDone

        boolean isDone()
        Test if done, i.e. result is available.
        Returns:
        True, if done.
      • getException

        java.lang.Exception getException()
        Get the exception, if any.
        Returns:
        The exception, if any, or null if the future is not yet done or succeeded without exception.
      • get

        E get()
        Get the result - blocking call.
        Returns:
        The future result.
      • get

        E get​(boolean realtime)
        Get the result - blocking call.
        Parameters:
        realtime - Flag, if wait should be realtime (in constrast to simulation time).
        Returns:
        The future result.
      • get

        E get​(long timeout)
        Get the result - blocking call.
        Parameters:
        timeout - The timeout in millis.
        Returns:
        The future result.
      • get

        E get​(long timeout,
              boolean realtime)
        Get the result - blocking call.
        Parameters:
        timeout - The timeout in millis.
        realtime - Flag, if wait should be realtime (in constrast to simulation time).
        Returns:
        The future result.
      • get

        E get​(ThreadSuspendable sus)
        Deprecated.
        - From 3.0. Use the version without suspendable. Will NOT use the suspendable given as parameter. Get the result - blocking call.
        Returns:
        The future result.
      • addResultListener

        void addResultListener​(IResultListener<E> listener)
        Add a result listener.
        Parameters:
        listener - The listener.
      • addResultListener

        void addResultListener​(IFunctionalResultListener<E> listener)
        Add an functional result listener, which is only called on success. Exceptions will be handled by DefaultResultListener.
        Parameters:
        listener - The listener.
      • addResultListener

        void addResultListener​(IFunctionalResultListener<E> sucListener,
                               IFunctionalExceptionListener exListener)
        Add a result listener by combining an OnSuccessListener and an OnExceptionListener.
        Parameters:
        sucListener - The listener that is called on success.
        exListener - The listener that is called on exceptions. Passing null enables default exception logging.
      • thenApply

        <T> IFuture<T> thenApply​(Function<? super E,​? extends T> function)
        Applies a function after the result is available, using the result of this Future as input.
        Parameters:
        function - Function that takes the result of this future as input and delivers t.
        Returns:
        Future of the result after the function has been applied.
      • thenApply

        <T> IFuture<T> thenApply​(Function<? super E,​? extends T> function,
                                 java.lang.Class<?> futuretype)
        Applies a function after the result is available, using the result of this Future as input.
        Parameters:
        function - Function that takes the result of this future as input and delivers t.
        futuretype - The type of the return future.
        Returns:
        Future of the result after the function has been applied.
      • thenCompose

        <T> IFuture<T> thenCompose​(Function<? super E,​IFuture<T>> function)
        The result of this future is delegated to the given (future-returning) function. The result of the function will be available in the returned future.
        Parameters:
        function - Function that takes the result of this future as input and delivers future(t).
        Returns:
        Future of the result of the second async call.
      • thenCompose

        <T> IFuture<T> thenCompose​(Function<? super E,​IFuture<T>> function,
                                   java.lang.Class<?> futuretype)
        The result of this future is delegated to the given (future-returning) function. The result of the function will be available in the returned future.
        Parameters:
        function - Function that takes the result of this future as input and delivers future(t).
        futuretype - The type of the return future. If null, a default future is created.
        Returns:
        Future of the result of the second async call.
      • thenAccept

        IFuture<java.lang.Void> thenAccept​(Consumer<? super E> consumer)
        Applies a synchronous function consuming the result after it is available.
        Parameters:
        consumer - Consumer that takes the result of this future as input and consumes it.
        Returns:
        Future of the result of the second async call.
      • thenAccept

        IFuture<java.lang.Void> thenAccept​(Consumer<? super E> consumer,
                                           java.lang.Class<?> futuretype)
        Applies a function consuming the result after it is available.
        Parameters:
        consumer - Consumer that takes the result of this future as input and consumes it.
        futuretype - The type of the return future. If null, a default future is created.
        Returns:
        Future of the second async call (returning void).
      • thenCombine

        <U,​V> IFuture<V> thenCombine​(IFuture<U> other,
                                           BiFunction<? super E,​? super U,​? extends V> function,
                                           java.lang.Class<?> futuretype)
        Combines this and another future and uses the given bifunction to calculate the result. Both future results are passed to the function as input.
        Parameters:
        function - BiFunction that takes the result of this and given other future as input and produces output.
        futuretype - The type of the return future. If null, a default future is created.
        Returns:
        Future of the second async call. Types: function is: E,U -> V
      • applyToEither

        <U> IFuture<U> applyToEither​(IFuture<E> other,
                                     Function<E,​U> fn,
                                     java.lang.Class<?> futuretype)
        The given function will be executed with either of the result of this and the given other future. The returned Future will receive the result of the function execution. If both futures return results, the first is used to call the function. If both futures throw exceptions, the last is passed to the returned future.
        Parameters:
        other - other future
        fn - function to receive result
        futuretype - The type of the return future. If null, a default future is created.
        Returns:
        Future of the async function execution.
      • acceptEither

        IFuture<java.lang.Void> acceptEither​(IFuture<E> other,
                                             Consumer<E> action,
                                             java.lang.Class<?> futuretype)
        The given consumer will be executed with either of the result of this and the given other future. The returned Future will receive the result of the function execution. If both futures return results, the first is used to call the function. If both futures throw exceptions, the last is passed to the returned future.
        Parameters:
        other - other future
        fn - function to receive result
        futuretype - The type of the return future. If null, a default future is created.
        Returns:
        Future of the async function execution.
      • exceptionally

        <T> void exceptionally​(Future<T> delegate)
        Sequential execution of async methods via implicit delegation.
        Parameters:
        function - Function that takes the result of this future as input and delivers future(t).
        ret - The
      • exceptionally

        IFuture<E> exceptionally​(Consumer<? super java.lang.Exception> consumer)
      • exceptionally

        IFuture<E> exceptionally​(Consumer<? super java.lang.Exception> function,
                                 java.lang.Class<?> consumer)
      • delegate

        void delegate​(Future<E> delegate)