public class AggregateFuture<T>
extends java.lang.Object
implements java.util.concurrent.Future<java.util.List<T>>
An AggregateFuture
encapsulates several Future
into a single one. The result of an aggregate future is the list of
results of all its components in the order in which they were added.
Constructor and Description |
---|
AggregateFuture(java.util.concurrent.Future<T>... futures)
Construct from a set of futures which is copied
internally.
|
AggregateFuture(java.util.List<java.util.concurrent.Future<T>> components)
Construct from a non-null list of components which is copied
internally.
|
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
Canceling an aggregate future succeeds only if canceling
all of its components succeeds.
|
java.util.List<T> |
get() |
java.util.List<T> |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled()
An aggregate is canceled iff at least one of its components is canceled.
|
boolean |
isDone()
An aggregate is done iff all of its components are done.
|
public AggregateFuture(java.util.concurrent.Future<T>... futures)
Construct from a set of futures which is copied internally.
public AggregateFuture(java.util.List<java.util.concurrent.Future<T>> components)
Construct from a non-null list of components which is copied internally.
public boolean cancel(boolean mayInterruptIfRunning)
Canceling an aggregate future succeeds only if canceling all of its components succeeds. Note that during the process some components may be canceled while others not which would lead to an inconsistent state.
cancel
in interface java.util.concurrent.Future<java.util.List<T>>
public java.util.List<T> get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<java.util.List<T>>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public java.util.List<T> get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<java.util.List<T>>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<java.util.List<T>>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<java.util.List<T>>