capnproto-java-rpc/runtime/src/main/java/org/capnproto/CompletableFutureWrapper.java
2020-10-22 15:55:11 +01:00

18 lines
No EOL
505 B
Java

package org.capnproto;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
public class CompletableFutureWrapper<T> extends CompletableFuture<T> {
public CompletableFutureWrapper(CompletionStage<T> other) {
other.toCompletableFuture().whenComplete((value, exc) -> {
if (exc == null) {
this.complete(value);
}
else {
this.completeExceptionally(exc);
}
});
}
}