All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.edgar615.util.vertx.task.Tuple2TaskImpl Maven / Gradle / Ivy

The newest version!
package com.github.edgar615.util.vertx.task;

import com.github.edgar615.util.vertx.function.Tuple2;
import io.vertx.core.CompositeFuture;
import io.vertx.core.Future;

/**
 * Created by Edgar on 2016/7/21.
 *
 * @author Edgar  Date 2016/7/21
 */
class Tuple2TaskImpl extends BaseTask> implements Tuple2Task {

  Tuple2TaskImpl(String name, Future futureT1, Future futureT2) {
    super(name, Future.>future());
    CompositeFuture compositeFuture = CompositeFuture.all(futureT1, futureT2);
    compositeFuture.setHandler(ar -> {
      if (ar.succeeded()) {
        T1 t1 = ar.result().resultAt(0);
        T2 t2 = ar.result().resultAt(1);
        complete(Tuple2.create(t1, t2));
      } else {
        fail(ar.cause());
      }
    });
  }

  Tuple2TaskImpl(Future futureT1, Future futureT2) {
    this("Tuple2Task:", futureT1, futureT2);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy