public static final class ClosingFuture.DeferredCloser
extends java.lang.Object
ClosingFuture
pipeline is
done.Modifier and Type | Field and Description |
---|---|
private ClosingFuture.CloseableList |
list |
Constructor and Description |
---|
DeferredCloser(ClosingFuture.CloseableList list) |
Modifier and Type | Method and Description |
---|---|
<C extends java.lang.Object & java.lang.AutoCloseable> |
eventuallyClose(C closeable,
java.util.concurrent.Executor closingExecutor)
Captures an object to be closed when a
ClosingFuture pipeline is done. |
private final ClosingFuture.CloseableList list
DeferredCloser(ClosingFuture.CloseableList list)
public <C extends java.lang.Object & java.lang.AutoCloseable> C eventuallyClose(C closeable, java.util.concurrent.Executor closingExecutor)
ClosingFuture
pipeline is done.
For users of the -jre
flavor of Guava, the object can be any AutoCloseable
. For users of the -android
flavor, the object must be a Closeable
. (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
is Closeable
. To support older versions, pass a wrapper
Closeable
with a method reference like cursor::close
.
Note that this method is still binary-compatible between flavors because the erasure of
its parameter type is Object
, not AutoCloseable
or Closeable
.
closeable
- the object to be closed (see notes above)closingExecutor
- the object will be closed on this executor