Class BaseFuture<V>

org.elasticsearch.common.util.concurrent.BaseFuture<V>
All Implemented Interfaces:
<V>
Direct Known Subclasses:
AdapterActionFuture, ListenableFuture, PlainTransportFuture

public abstract class BaseFuture<V> extends implements <V>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
     
    boolean
    cancel​(boolean mayInterruptIfRunning)
     
    protected void
    done​(boolean success)
    Called when the BaseFuture is completed.
    get()
    get​(long timeout,  unit)
    protected void
    Subclasses can override this method to implement interruption of the future's computation.
    boolean
     
    boolean
     
    protected boolean
    set​(V value)
    Subclasses should invoke this method to set the result of the computation to value.
    protected boolean
     throwable)
    Subclasses should invoke this method to set the result of the computation to an error, throwable.

    Methods inherited from class java.lang.

    , , , , , , , , , ,
  • Constructor Details

    • BaseFuture

      public BaseFuture()
  • Method Details

    • get

      public V get(long timeout,  unit) throws , ,

      The default BaseFuture implementation throws InterruptedException if the current thread is interrupted before or during the call, even if the value is already available.

      Specified by:
       in interface <V>
      Throws:
      - if the current thread was interrupted before or during the call (optional but recommended).
    • get

      public V get() throws ,

      The default BaseFuture implementation throws InterruptedException if the current thread is interrupted before or during the call, even if the value is already available.

      Specified by:
       in interface <V>
      Throws:
      - if the current thread was interrupted before or during the call (optional but recommended).
    • blockingAllowed

      protected boolean blockingAllowed()
    • isDone

      public boolean isDone()
      Specified by:
       in interface <V>
    • isCancelled

      public boolean isCancelled()
      Specified by:
       in interface <V>
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      Specified by:
       in interface <V>
    • interruptTask

      protected void interruptTask()
      Subclasses can override this method to implement interruption of the future's computation. The method is invoked automatically by a successful call to cancel(true).

      The default implementation does nothing.

      Since:
      10.0
    • set

      protected boolean set(@Nullable V value)
      Subclasses should invoke this method to set the result of the computation to value. This will set the state of the future to BaseFuture.Sync.COMPLETED and call done(boolean) if the state was successfully changed.
      Parameters:
      value - the value that was the result of the task.
      Returns:
      true if the state was successfully changed.
    • setException

      protected boolean setException( throwable)
      Subclasses should invoke this method to set the result of the computation to an error, throwable. This will set the state of the future to BaseFuture.Sync.COMPLETED and call done(boolean) if the state was successfully changed.
      Parameters:
      throwable - the exception that the task failed with.
      Returns:
      true if the state was successfully changed.
      Throws:
      - if the throwable was an .
    • done

      protected void done(boolean success)
      Called when the BaseFuture is completed. The success boolean indicates if the BaseFuture was successfully completed (the value is true). In the cases the BaseFuture was completed with an error or cancelled the value is false.
      Parameters:
      success - indicates if the BaseFuture was completed with success (true); in other cases it equals to false