Class FutureCompletion

  • All Implemented Interfaces:
    com.google.common.util.concurrent.ListenableFuture<java.lang.Boolean>, CompletionHandler, java.util.concurrent.Future<java.lang.Boolean>

    public final class FutureCompletion
    extends com.google.common.util.concurrent.AbstractFuture<java.lang.Boolean>
    implements CompletionHandler

    This class provides an implementation of CompletionHandler that allows you to wait for either completed() or failed(Throwable) to be called. If failed() was called, the corresponding Throwable will be rethrown when calling either of the get() methods. Unless an exception is thrown, the get() methods will always return Boolean.TRUE.

    Notice that calling cancel(boolean) throws an UnsupportedOperationException.

    Author:
    Simon Thoresen Hult
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)  
      void completed()
      Invoked when an operation has completed.
      void failed​(java.lang.Throwable t)
      Invoked when an operation fails.
      boolean isCancelled()  
      • Methods inherited from class com.google.common.util.concurrent.AbstractFuture

        addListener, afterDone, get, get, interruptTask, isDone, set, setException, setFuture, wasInterrupted
      • Methods inherited from class java.lang.Object

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

      • FutureCompletion

        public FutureCompletion()
    • Method Detail

      • failed

        public void failed​(java.lang.Throwable t)
        Description copied from interface: CompletionHandler
        Invoked when an operation fails. Notice that you MUST call either this or CompletionHandler.completed() to release the internal Container reference. Failure to do so will prevent the Container from ever shutting down.
        Specified by:
        failed in interface CompletionHandler
        Parameters:
        t - The exception to indicate why the I/O operation failed.
      • cancel

        public final boolean cancel​(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<java.lang.Boolean>
        Overrides:
        cancel in class com.google.common.util.concurrent.AbstractFuture<java.lang.Boolean>
      • isCancelled

        public final boolean isCancelled()
        Specified by:
        isCancelled in interface java.util.concurrent.Future<java.lang.Boolean>
        Overrides:
        isCancelled in class com.google.common.util.concurrent.AbstractFuture<java.lang.Boolean>