类 SettableFutureAggregator

java.lang.Object
cn.taketoday.util.concurrent.SettableFutureAggregator
所有已实现的接口:
FutureListener<ListenableFuture<?>>, EventListener

public final class SettableFutureAggregator extends Object implements FutureListener<ListenableFuture<?>>

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
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • add

      public void add(ListenableFuture future)
      Adds a new future to be combined. New futures may be added until an aggregate SettableFuture is added via the finish(SettableFuture) method.
      参数:
      future - the future to add to this SettableFuture combiner
    • addAll

      public void addAll(ListenableFuture... futures)
      Adds new futures to be combined. New futures may be added until an aggregate SettableFuture is added via the finish(SettableFuture) method.
      参数:
      futures - the futures to add to this SettableFuture combiner
    • finish

      public void finish(SettableFuture<Void> aggregateFuture)

      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) or addAll(ListenableFuture[]) methods.

      参数:
      aggregateFuture - the SettableFuture to notify when all combined futures have finished
    • trySettableFuture

      private boolean trySettableFuture(SettableFuture<Void> aggregateFuture)
    • checkAddAllowed

      private void checkAddAllowed()
    • operationComplete

      public void operationComplete(ListenableFuture<?> future)
      从接口复制的说明: FutureListener
      Invoked when the operation associated with the ListenableFuture has been completed.
      指定者:
      operationComplete 在接口中 FutureListener<ListenableFuture<?>>
      参数:
      future - the source ListenableFuture which called this callback