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.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
public class DependencyLoader { public class DependencyLoader {
@ -99,20 +98,8 @@ public class DependencyLoader {
} }
private CompletableFuture<Void> download(ClasspathAppender appender) { private CompletableFuture<Void> download(ClasspathAppender appender) {
CompletableFuture<Void> future = new CompletableFuture<>(); return dependencyManager.downloadAll(executor, REPOSITORIES)
executor.execute(() -> { .thenCompose(v -> dependencyManager.relocateAll(executor))
try { .thenCompose(v -> dependencyManager.loadAll(executor, appender));
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;
} }
} }

View File

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