Package org.apache.druid.common.guava
Class FutureBox
java.lang.Object
org.apache.druid.common.guava.FutureBox
- All Implemented Interfaces:
Closeable,AutoCloseable
Box for tracking pending futures. Allows cancellation of all pending futures.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the box, canceling all currently-pending futures.intReturns the number of currently-pending futures.<R> com.google.common.util.concurrent.ListenableFuture<R>register(com.google.common.util.concurrent.ListenableFuture<R> future) Adds a future to the box.
-
Constructor Details
-
FutureBox
public FutureBox()
-
-
Method Details
-
pendingCount
public int pendingCount()Returns the number of currently-pending futures. -
register
public <R> com.google.common.util.concurrent.ListenableFuture<R> register(com.google.common.util.concurrent.ListenableFuture<R> future) Adds a future to the box. Ifclose()had previously been called, the future is immediately canceled. -
close
public void close()Closes the box, canceling all currently-pending futures.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-