Skip to content

Commit

Permalink
Finished dealing with non-defined contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
DavyLandman committed Oct 13, 2021
1 parent 6c87285 commit 98a56e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,15 @@ public InterruptibleFuture<Void> executeCommand(String command) {
}), () -> {});
}

private <T> InterruptibleFuture<T> execFunction(String name, CompletableFuture<IFunction> target, T defaultResult, IValue... args) {
private <T> InterruptibleFuture<T> execFunction(String name, CompletableFuture<@Nullable IFunction> target, T defaultResult, IValue... args) {
return InterruptibleFuture.flatten(
target.thenApply(s -> EvaluatorUtil.runEvaluator(name, eval,e -> s.call(args), defaultResult, exec))
target.thenApply(s -> {
if (s == null) {
logger.trace("Not running {} since it's not defined for: {}", name, this.name);
return InterruptibleFuture.completedFuture(defaultResult);
}
return EvaluatorUtil.runEvaluator(name, eval,e -> s.call(args), defaultResult, exec);
})
, exec);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public InterruptibleFuture<Void> thenAccept(Consumer<T> func) {
return new InterruptibleFuture<>(future.thenAccept(func), interrupt);
}

public static <T> InterruptibleFuture<T> completedFuture(T result) {
return new InterruptibleFuture<>(CompletableFuture.completedFuture(result), () -> {});
}

/**
* Turn an completable future with a interruptible future inside into a
* normal interruptible future by inlining them
Expand Down

0 comments on commit 98a56e3

Please sign in to comment.