Class FutureResult<T>

  • All Implemented Interfaces:
    java.util.concurrent.Future<T>

    public class FutureResult<T>
    extends java.lang.Object
    implements java.util.concurrent.Future<T>
    A class that implements the future completion of a request.
    • Constructor Summary

      Constructors 
      Constructor Description
      FutureResult()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void await()
      Await the completion of this request
      boolean await​(long timeout, java.util.concurrent.TimeUnit unit)
      Await the completion of this request (up to the given time interval)
      boolean cancel​(boolean mayInterruptIfRunning)  
      boolean completed()
      Has the request completed?
      void done​(T result, java.lang.Exception error)
      Mark this request as complete and unblock any threads waiting on its completion.
      java.lang.Exception error()
      The error thrown (generally on the server) while processing this request
      T get()  
      T get​(long timeout, java.util.concurrent.TimeUnit unit)  
      boolean isCancelled()  
      boolean isDone()  
      T result()
      The result for the request
      • Methods inherited from class java.lang.Object

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

      • FutureResult

        public FutureResult()
    • Method Detail

      • done

        public void done​(T result,
                         java.lang.Exception error)
        Mark this request as complete and unblock any threads waiting on its completion.
        Parameters:
        result - The result for this request
        error - The error that occurred if there was one, or null.
      • await

        public void await()
                   throws java.lang.InterruptedException
        Await the completion of this request
        Throws:
        java.lang.InterruptedException
      • await

        public boolean await​(long timeout,
                             java.util.concurrent.TimeUnit unit)
                      throws java.lang.InterruptedException
        Await the completion of this request (up to the given time interval)
        Parameters:
        timeout - The maximum time to wait
        unit - The unit for the max time
        Returns:
        true if the request completed, false if we timed out
        Throws:
        java.lang.InterruptedException
      • result

        public T result()
        The result for the request
      • error

        public java.lang.Exception error()
        The error thrown (generally on the server) while processing this request
      • completed

        public boolean completed()
        Has the request completed?
      • cancel

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

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

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

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

        public T 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<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException