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.Object
An object that can capture objects to be closed later, when aClosingFuture
pipeline is done.
-
-
Field Summary
Fields Modifier and Type Field Description private ClosingFuture.CloseableList
list
-
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 aClosingFuture
pipeline 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 aClosingFuture
pipeline is done.For users of the
-jre
flavor of Guava, the object can be anyAutoCloseable
. For users of the-android
flavor, 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
Cursor
isCloseable
. To support older versions, pass a wrapperCloseable
with a method reference likecursor::close
.Note that this method is still binary-compatible between flavors because the erasure of its parameter type is
Object
, notAutoCloseable
orCloseable
.- Parameters:
closeable
- the object to be closed (see notes above)closingExecutor
- the object will be closed on this executor- Returns:
- the first argument
-
-