Package com.yahoo.jdisc.handler
Class FutureCompletion
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractFuture<java.lang.Boolean>
-
- com.yahoo.jdisc.handler.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 eithercompleted()
orfailed(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 Summary
Constructors Constructor Description FutureCompletion()
-
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()
-
-
-
Method Detail
-
completed
public void completed()
Description copied from interface:CompletionHandler
Invoked when an operation has completed. Notice that you MUST call either this orCompletionHandler.failed(Throwable)
to release the internalContainer
reference. Failure to do so will prevent the Container from ever shutting down.- Specified by:
completed
in interfaceCompletionHandler
-
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 orCompletionHandler.completed()
to release the internalContainer
reference. Failure to do so will prevent the Container from ever shutting down.- Specified by:
failed
in interfaceCompletionHandler
- Parameters:
t
- The exception to indicate why the I/O operation failed.
-
cancel
public final boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interfacejava.util.concurrent.Future<java.lang.Boolean>
- Overrides:
cancel
in classcom.google.common.util.concurrent.AbstractFuture<java.lang.Boolean>
-
isCancelled
public final boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<java.lang.Boolean>
- Overrides:
isCancelled
in classcom.google.common.util.concurrent.AbstractFuture<java.lang.Boolean>
-
-