com.github.edgar615.util.vertx.task.Tuple3TaskImpl Maven / Gradle / Ivy
The newest version!
package com.github.edgar615.util.vertx.task;
import com.github.edgar615.util.vertx.function.Tuple3;
import io.vertx.core.CompositeFuture;
import io.vertx.core.Future;
/**
* Created by Edgar on 2016/7/21.
*
* @author Edgar Date 2016/7/21
*/
class Tuple3TaskImpl extends BaseTask> implements Tuple3Task {
Tuple3TaskImpl(String name, Future futureT1, Future futureT2, Future futureT3) {
super(name, Future.>future());
CompositeFuture compositeFuture = CompositeFuture.all(futureT1, futureT2, futureT3);
compositeFuture.setHandler(ar -> {
if (ar.succeeded()) {
T1 t1 = ar.result().resultAt(0);
T2 t2 = ar.result().resultAt(1);
T3 t3 = ar.result().resultAt(2);
complete(Tuple3.create(t1, t2, t3));
} else {
fail(ar.cause());
}
});
}
Tuple3TaskImpl(Future futureT1, Future futureT2, Future futureT3) {
this("Tuple3Task:", futureT1, futureT2, futureT3);
}
}