类 SettableFutureAggregator
- 所有已实现的接口:
FutureListener<ListenableFuture<?>>,EventListener
A SettableFuture combiner monitors the outcome of a number of discrete futures, then notifies a final, aggregate SettableFuture when all of the combined futures are finished. The aggregate SettableFuture will succeed if and only if all of the combined futures succeed. If any of the combined futures fail, the aggregate SettableFuture will fail. The cause failure for the aggregate SettableFuture will be the failure for one of the failed combined futures; if more than one of the combined futures fails, exactly which cause of failure will be assigned to the aggregate SettableFuture is undefined.
Callers may populate a SettableFuture combiner with any number of futures
to be combined via the add(ListenableFuture)
and addAll(ListenableFuture[]) methods.
When all futures to be combined have been added, callers must provide
an aggregate SettableFuture to be notified when all combined SettableFutures have
finished via the finish(SettableFuture) method.
This implementation is NOT thread-safe and all
methods must be called from the Executor thread.
- 从以下版本开始:
- 4.0
- 作者:
- Harry Yang
-
字段概要
字段修饰符和类型字段说明private SettableFuture<Void>private Throwableprivate intprivate final Executorprivate int -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidadd(ListenableFuture future) Adds a new future to be combined.voidaddAll(ListenableFuture... futures) Adds new futures to be combined.private voidvoidfinish(SettableFuture<Void> aggregateFuture) Sets the SettableFuture to be notified when all combined futures have finished.voidoperationComplete(ListenableFuture<?> future) Invoked when the operation associated with theListenableFuturehas been completed.private booleantrySettableFuture(SettableFuture<Void> aggregateFuture)
-
字段详细资料
-
expectedCount
private int expectedCount -
doneCount
private int doneCount -
cause
-
aggregateFuture
-
executor
-
-
构造器详细资料
-
SettableFutureAggregator
public SettableFutureAggregator() -
SettableFutureAggregator
TheExecutorto use for notifications. You must calladd(ListenableFuture),addAll(ListenableFuture[])andfinish(SettableFuture)from within theExecutorthread.- 参数:
executor- theExecutorto use for notifications.
-
-
方法详细资料
-
add
Adds a new future to be combined. New futures may be added until an aggregate SettableFuture is added via thefinish(SettableFuture)method.- 参数:
future- the future to add to this SettableFuture combiner
-
addAll
Adds new futures to be combined. New futures may be added until an aggregate SettableFuture is added via thefinish(SettableFuture)method.- 参数:
futures- the futures to add to this SettableFuture combiner
-
finish
Sets the SettableFuture to be notified when all combined futures have finished. If all combined futures succeed, then the aggregate SettableFuture will succeed. If one or more combined futures fails, then the aggregate SettableFuture will fail with the cause of one of the failed futures. If more than one combined future fails, then exactly which failure will be assigned to the aggregate SettableFuture is undefined.
After this method is called, no more futures may be added via the
add(ListenableFuture)oraddAll(ListenableFuture[])methods.- 参数:
aggregateFuture- the SettableFuture to notify when all combined futures have finished
-
trySettableFuture
-
checkAddAllowed
private void checkAddAllowed() -
operationComplete
从接口复制的说明:FutureListenerInvoked when the operation associated with theListenableFuturehas been completed.- 指定者:
operationComplete在接口中FutureListener<ListenableFuture<?>>- 参数:
future- the sourceListenableFuturewhich called this callback
-