* Redesigned idle timeout handling to prevent selecting wrong player for timeout.

This commit is contained in:
LevelX2 2014-12-27 17:31:52 +01:00
parent fba13b26ac
commit dd8a11ba5c
7 changed files with 86 additions and 88 deletions

View file

@ -1,11 +1,10 @@
package mage.server.util;
import mage.game.Game;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.game.Game;
import mage.players.Player;
/**
* @author nantuko
@ -13,7 +12,7 @@ import java.util.UUID;
public class Splitter {
public static List<UUID> split(Game game, UUID playerId) {
List<UUID> players = new ArrayList<UUID>();
List<UUID> players = new ArrayList<>();
//players.add(playerId); // add original player
Player player = game.getPlayer(playerId);
if (player != null && player.getTurnControlledBy() != null) {

View file

@ -43,7 +43,8 @@ public class ThreadExecutor {
private static final ExecutorService callExecutor = Executors.newCachedThreadPool();
private static final ExecutorService gameExecutor = Executors.newFixedThreadPool(ConfigSettings.getInstance().getMaxGameThreads());
private static final ScheduledExecutorService timeoutExecutor = Executors.newScheduledThreadPool(5);
private static final ScheduledExecutorService timeoutExecutor = Executors.newScheduledThreadPool(4);
private static final ScheduledExecutorService timeoutIdleExecutor = Executors.newScheduledThreadPool(4);
/**
* noxx: what the settings below do is setting the ability to keep OS threads for new games for 60 seconds
@ -62,7 +63,10 @@ public class ThreadExecutor {
((ThreadPoolExecutor)gameExecutor).setThreadFactory(new XMageThreadFactory("GAME"));
((ThreadPoolExecutor)timeoutExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
((ThreadPoolExecutor)timeoutExecutor).allowCoreThreadTimeOut(true);
((ThreadPoolExecutor)timeoutExecutor).setThreadFactory(new XMageThreadFactory("TIME"));
((ThreadPoolExecutor)timeoutExecutor).setThreadFactory(new XMageThreadFactory("TIMEOUT"));
((ThreadPoolExecutor)timeoutIdleExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
((ThreadPoolExecutor)timeoutIdleExecutor).allowCoreThreadTimeOut(true);
((ThreadPoolExecutor)timeoutIdleExecutor).setThreadFactory(new XMageThreadFactory("TIMEOUT_IDLE"));
}
private static final ThreadExecutor INSTANCE = new ThreadExecutor();
@ -91,6 +95,10 @@ public class ThreadExecutor {
public ScheduledExecutorService getTimeoutExecutor() {
return timeoutExecutor;
}
public ScheduledExecutorService getTimeoutIdleExecutor() {
return timeoutIdleExecutor;
}
}