forked from External/mage
server: improved tourney threads naming, added max tourneys limit (max games / 10);
This commit is contained in:
parent
48c1bbdc01
commit
199345db07
4 changed files with 27 additions and 4 deletions
|
|
@ -14,8 +14,13 @@ public class ThreadExecutorImpl implements ThreadExecutor {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(ThreadExecutorImpl.class);
|
||||
|
||||
// used for max tourney limit, but without new config setting
|
||||
// example: server can have 100 games and 10 tourney at a time
|
||||
private final int GAMES_PER_TOURNEY_RATIO = 100 / 10;
|
||||
|
||||
private final ExecutorService callExecutor; // shareable threads to run single task (example: save new game settings from a user, send chat message, etc)
|
||||
private final ExecutorService gameExecutor; // game threads to run long tasks, one per game (example: run game and wait user's feedback)
|
||||
private final ExecutorService tourneyExecutor; // tourney threads (example: make draft, construction, build and run other game threads)
|
||||
private final ScheduledExecutorService timeoutExecutor;
|
||||
private final ScheduledExecutorService timeoutIdleExecutor;
|
||||
private final ScheduledExecutorService serverHealthExecutor;
|
||||
|
|
@ -44,15 +49,21 @@ public class ThreadExecutorImpl implements ThreadExecutor {
|
|||
((ThreadPoolExecutor) gameExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) gameExecutor).setThreadFactory(new XMageThreadFactory("GAME"));
|
||||
|
||||
//tourney = Executors.newFixedThreadPool(config.getMaxGameThreads() / GAMES_PER_TOURNEY_RATIO);
|
||||
tourneyExecutor = new FixedThreadPoolWithException(config.getMaxGameThreads() / GAMES_PER_TOURNEY_RATIO);
|
||||
((ThreadPoolExecutor) tourneyExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
|
||||
((ThreadPoolExecutor) tourneyExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) tourneyExecutor).setThreadFactory(new XMageThreadFactory("TOURNEY"));
|
||||
|
||||
timeoutExecutor = Executors.newScheduledThreadPool(4);
|
||||
((ThreadPoolExecutor) timeoutExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
|
||||
((ThreadPoolExecutor) timeoutExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) timeoutExecutor).setThreadFactory(new XMageThreadFactory("TIMEOUT"));
|
||||
((ThreadPoolExecutor) timeoutExecutor).setThreadFactory(new XMageThreadFactory("XMAGE TIMEOUT"));
|
||||
|
||||
timeoutIdleExecutor = Executors.newScheduledThreadPool(4);
|
||||
((ThreadPoolExecutor) timeoutIdleExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
|
||||
((ThreadPoolExecutor) timeoutIdleExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) timeoutIdleExecutor).setThreadFactory(new XMageThreadFactory("TIMEOUT_IDLE"));
|
||||
((ThreadPoolExecutor) timeoutIdleExecutor).setThreadFactory(new XMageThreadFactory("XMAGE TIMEOUT_IDLE"));
|
||||
|
||||
serverHealthExecutor = Executors.newSingleThreadScheduledExecutor(new XMageThreadFactory("HEALTH"));
|
||||
}
|
||||
|
|
@ -109,6 +120,11 @@ public class ThreadExecutorImpl implements ThreadExecutor {
|
|||
return callExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutorService getTourneyExecutor() {
|
||||
return tourneyExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutorService getGameExecutor() {
|
||||
return gameExecutor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue