Class ClosingFuture.ValueAndCloser<V>
- java.lang.Object
-
- com.google.common.util.concurrent.ClosingFuture.ValueAndCloser<V>
-
- Type Parameters:
V
- the type of the value of a successful operation
- Enclosing class:
- ClosingFuture<V>
public static final class ClosingFuture.ValueAndCloser<V> extends java.lang.Object
An object that holds the final result of an asynchronousClosingFuture
operation and allows the user to close all the closeable objects that were captured during it for later closing.The asynchronous operation will have completed before this object is created.
-
-
Field Summary
Fields Modifier and Type Field Description private ClosingFuture<? extends V>
closingFuture
-
Constructor Summary
Constructors Constructor Description ValueAndCloser(ClosingFuture<? extends V> closingFuture)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeAsync()
Starts closing all closeable objects captured during theClosingFuture
's asynchronous operation on theExecutor
s specified by calls toDeferredCloser#eventuallyClose(Closeable, Executor)
.V
get()
Returns the final value of the associatedClosingFuture
, or throws an exception asFuture.get()
would.
-
-
-
Field Detail
-
closingFuture
private final ClosingFuture<? extends V> closingFuture
-
-
Constructor Detail
-
ValueAndCloser
ValueAndCloser(ClosingFuture<? extends V> closingFuture)
-
-
Method Detail
-
get
public V get() throws java.util.concurrent.ExecutionException
Returns the final value of the associatedClosingFuture
, or throws an exception asFuture.get()
would.Because the asynchronous operation has already completed, this method is synchronous and returns immediately.
- Throws:
java.util.concurrent.CancellationException
- if the computation was cancelledjava.util.concurrent.ExecutionException
- if the computation threw an exception
-
closeAsync
public void closeAsync()
Starts closing all closeable objects captured during theClosingFuture
's asynchronous operation on theExecutor
s specified by calls toDeferredCloser#eventuallyClose(Closeable, Executor)
.If any such calls specified
MoreExecutors.directExecutor()
, those objects will be closed synchronously.Idempotent: objects will be closed at most once.
-
-