9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 19:49:06 +00:00
This commit is contained in:
cyberpwn
2021-08-27 01:35:23 -04:00
parent 08865dc218
commit a5270ccea8
4 changed files with 33 additions and 9 deletions

View File

@@ -48,7 +48,12 @@ public interface Job {
return (double) getWorkCompleted() / (double) getTotalWork();
}
default void execute(VolmitSender sender) {
execute(sender, () -> {});
}
default void execute(VolmitSender sender, Runnable whenComplete) {
PrecisionStopwatch p = PrecisionStopwatch.start();
CompletableFuture<?> f = J.afut(this::execute);
int c = J.ar(() -> {
@@ -61,6 +66,7 @@ public interface Job {
f.whenComplete((fs, ff) -> {
J.car(c);
sender.sendMessage("Completed " + getName() + " in " + Form.duration(p.getMilliseconds(), 1));
whenComplete.run();
});
}
}