mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Moved async runner to virtual thread
This commit is contained in:
@@ -22,10 +22,8 @@ public class AsyncTournamentRunner implements TournamentRunner {
|
|||||||
String gameType
|
String gameType
|
||||||
) {
|
) {
|
||||||
|
|
||||||
ExecutorService matchExecutor =
|
ExecutorService matchExecutor = Executors.newVirtualThreadPerTaskExecutor();
|
||||||
Executors.newFixedThreadPool(
|
ExecutorService scoringExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||||
Runtime.getRuntime().availableProcessors()
|
|
||||||
);
|
|
||||||
|
|
||||||
Queue<TournamentMatch> pendingMatches = new ConcurrentLinkedQueue<>();
|
Queue<TournamentMatch> pendingMatches = new ConcurrentLinkedQueue<>();
|
||||||
matchMaker.forEach(pendingMatches::add);
|
matchMaker.forEach(pendingMatches::add);
|
||||||
@@ -56,7 +54,11 @@ public class AsyncTournamentRunner implements TournamentRunner {
|
|||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
GameResultFuture game = matchRunner.submit(gameType, turnTime, a, b);
|
GameResultFuture game = matchRunner.submit(gameType, turnTime, a, b);
|
||||||
scoreSystems.forEach(s -> s.result(match, game.result().join()));
|
|
||||||
|
CompletableFuture.runAsync(
|
||||||
|
() -> scoreSystems.forEach(s -> s.result(match, game.result().join())),
|
||||||
|
scoringExecutor
|
||||||
|
).join();
|
||||||
} finally {
|
} finally {
|
||||||
a.clearGame();
|
a.clearGame();
|
||||||
b.clearGame();
|
b.clearGame();
|
||||||
|
|||||||
Reference in New Issue
Block a user