Class ClosingFuture.DeferredCloser
- java.lang.Object
-
- com.google.common.util.concurrent.ClosingFuture.DeferredCloser
-
- Enclosing class:
- ClosingFuture<V>
public static final class ClosingFuture.DeferredCloser extends java.lang.ObjectAn object that can capture objects to be closed later, when aClosingFuturepipeline is done.
-
-
Field Summary
Fields Modifier and Type Field Description private ClosingFuture.CloseableListlist
-
Constructor Summary
Constructors Constructor Description DeferredCloser(ClosingFuture.CloseableList list)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <C extends java.lang.Object & java.lang.AutoCloseable>
CeventuallyClose(C closeable, java.util.concurrent.Executor closingExecutor)Captures an object to be closed when aClosingFuturepipeline is done.
-
-
-
Field Detail
-
list
private final ClosingFuture.CloseableList list
-
-
Constructor Detail
-
DeferredCloser
DeferredCloser(ClosingFuture.CloseableList list)
-
-
Method Detail
-
eventuallyClose
public <C extends java.lang.Object & java.lang.AutoCloseable> C eventuallyClose(C closeable, java.util.concurrent.Executor closingExecutor)Captures an object to be closed when aClosingFuturepipeline is done.For users of the
-jreflavor of Guava, the object can be anyAutoCloseable. For users of the-androidflavor, the object must be aCloseable. (For more about the flavors, see Adding Guava to your build.)Be careful when targeting an older SDK than you are building against (most commonly when building for Android): Ensure that any object you pass implements the interface not just in your current SDK version but also at the oldest version you support. For example, API Level 16 is the first version in which
CursorisCloseable. To support older versions, pass a wrapperCloseablewith a method reference likecursor::close.Note that this method is still binary-compatible between flavors because the erasure of its parameter type is
Object, notAutoCloseableorCloseable.- Parameters:
closeable- the object to be closed (see notes above)closingExecutor- the object will be closed on this executor- Returns:
- the first argument
-
-