Fix ThreadPoolExecutor queue, DependencyLoader unnecessary executor inside executor

This commit is contained in:
Vankka 2023-07-20 22:52:42 +03:00
parent a9fd9a9fc8
commit 061ab08e2d
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0
2 changed files with 4 additions and 17 deletions

View File

@ -31,7 +31,6 @@ import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.Executor;
public class DependencyLoader {
@ -99,20 +98,8 @@ public class DependencyLoader {
}
private CompletableFuture<Void> download(ClasspathAppender appender) {
CompletableFuture<Void> future = new CompletableFuture<>();
executor.execute(() -> {
try {
dependencyManager.downloadAll(executor, REPOSITORIES).join();
dependencyManager.relocateAll(executor).join();
dependencyManager.loadAll(executor, appender).join();
future.complete(null);
} catch (CompletionException e) {
future.completeExceptionally(e.getCause());
} catch (Throwable t) {
future.completeExceptionally(t);
}
});
return future;
return dependencyManager.downloadAll(executor, REPOSITORIES)
.thenCompose(v -> dependencyManager.relocateAll(executor))
.thenCompose(v -> dependencyManager.loadAll(executor, appender));
}
}

View File

@ -46,7 +46,7 @@ public class StandardScheduler implements Scheduler {
Math.max(4, Runtime.getRuntime().availableProcessors() - 2),
/* Timeout */
60, TimeUnit.SECONDS,
new SynchronousQueue<>(),
new LinkedBlockingQueue<>(),
new CountingThreadFactory(Scheduler.THREAD_NAME_PREFIX + "Executor #%s")
),
new ScheduledThreadPoolExecutor(