forked from External/mage
Fixed thread pool leak and work queue growing.
This commit is contained in:
parent
c7ae032d5a
commit
cfa779661d
5 changed files with 24 additions and 4 deletions
|
|
@ -34,6 +34,7 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import mage.game.Game;
|
||||
import mage.MageException;
|
||||
|
|
@ -172,6 +173,8 @@ public class GameSession extends GameWatcher {
|
|||
private synchronized void cancelTimeout() {
|
||||
if (futureTimeout != null) {
|
||||
futureTimeout.cancel(false);
|
||||
((ThreadPoolExecutor)timeoutExecutor).getQueue().remove(futureTimeout);
|
||||
//System.out.println("tasks:"+ ((ThreadPoolExecutor)timeoutExecutor).getTaskCount());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,4 +197,9 @@ public class GameSession extends GameWatcher {
|
|||
cancelTimeout();
|
||||
game.getPlayer(playerId).setResponseInteger(data);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
cancelTimeout();
|
||||
setKilled();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue