Class FutureCompletion

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

    public final class FutureCompletion
    extends com.google.common.util.concurrent.AbstractFuture<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
    • Constructor Detail

      • FutureCompletion

        public FutureCompletion()
    • Method Detail

      • failed

        public void failed​(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 Future<Boolean>
        Overrides:
        cancel in class com.google.common.util.concurrent.AbstractFuture<Boolean>
      • isCancelled

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