Class ClosingFuture.DeferredCloser
- java.lang.Object
-
- com.google.common.util.concurrent.ClosingFuture.DeferredCloser
-
- Enclosing class:
- ClosingFuture<V>
public static final class ClosingFuture.DeferredCloser extends Object
An object that can capture objects to be closed later, when aClosingFuture
pipeline is done.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <C extends @Nullable Object & @Nullable AutoCloseable>
CeventuallyClose(C closeable, Executor closingExecutor)
Captures an object to be closed when aClosingFuture
pipeline is done.
-
-
-
Method Detail
-
eventuallyClose
@CanIgnoreReturnValue public <C extends @Nullable Object & @Nullable AutoCloseable> C eventuallyClose(C closeable, 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
-
-