Class FuturePromise<C>

  • All Implemented Interfaces:
    java.util.concurrent.Future<C>, Promise<C>

    public class FuturePromise<C>
    extends java.lang.Object
    implements java.util.concurrent.Future<C>, Promise<C>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)  
      void failed​(java.lang.Throwable cause)
      Callback invoked when the operation fails.
      C get()  
      C get​(long timeout, java.util.concurrent.TimeUnit unit)  
      C getOrThrow()
      Return the result if completed successfully or in the case of failure, throw the Exception/Error, or an ExecutionException wrapping the cause if it is neither an Exception or Error.
      boolean isCancelled()  
      boolean isDone()  
      static void rethrow​(java.util.concurrent.ExecutionException e)  
      void succeeded​(C result)
      Callback invoked when the operation completes.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • FuturePromise

        public FuturePromise()
      • FuturePromise

        public FuturePromise​(C result)
      • FuturePromise

        public FuturePromise​(C ctx,
                             java.lang.Throwable failed)
    • Method Detail

      • succeeded

        public void succeeded​(C result)
        Description copied from interface: Promise

        Callback invoked when the operation completes.

        Specified by:
        succeeded in interface Promise<C>
        Parameters:
        result - the context
        See Also:
        Promise.failed(Throwable)
      • failed

        public void failed​(java.lang.Throwable cause)
        Description copied from interface: Promise

        Callback invoked when the operation fails.

        Specified by:
        failed in interface Promise<C>
        Parameters:
        cause - the reason for the operation failure
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<C>
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface java.util.concurrent.Future<C>
      • isDone

        public boolean isDone()
        Specified by:
        isDone in interface java.util.concurrent.Future<C>
      • get

        public C get()
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException
        Specified by:
        get in interface java.util.concurrent.Future<C>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getOrThrow

        public C getOrThrow()
                     throws java.lang.Exception
        Return the result if completed successfully or in the case of failure, throw the Exception/Error, or an ExecutionException wrapping the cause if it is neither an Exception or Error.
        Returns:
        the computed result
        Throws:
        java.lang.Exception - if the cause is an Exception or Error, otherwise an ExecutionException wrapping the cause
      • get

        public C get​(long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException,
                     java.util.concurrent.TimeoutException
        Specified by:
        get in interface java.util.concurrent.Future<C>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
      • rethrow

        public static void rethrow​(java.util.concurrent.ExecutionException e)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object