Package org.swtpra1
Class TaskScheduler
- java.lang.Object
-
- org.swtpra1.TaskScheduler
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
public class TaskScheduler extends java.lang.Object implements java.beans.PropertyChangeListener
Class to wrap our threaded tasks. This includes: - polling data - generating leaderboard from results - serializing the object
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_REFRESH_TIME
Since turn time is 10 seconds by default (and we expect them to be used in most cases, gathering updates every 5 seconds should be plenty often.
-
Constructor Summary
Constructors Constructor Description TaskScheduler(TournamentControl tournamentControl)
Schedules tasks.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
outputLeaderboardToFile()
Writes the current results of the tournament into a html table and writes to "htmlLeaderboardFile".void
propertyChange(java.beans.PropertyChangeEvent evt)
Reacts to any PropertyChangeEvents that have been registered properly.void
startRefresh()
Starts polling the data from the gameserver at a fixed rate (5000ms by default), updating the local data.void
stopRefresh()
Stops any new polling of game data, while finishing up any remaining requests.
-
-
-
Field Detail
-
DEFAULT_REFRESH_TIME
public static final long DEFAULT_REFRESH_TIME
Since turn time is 10 seconds by default (and we expect them to be used in most cases, gathering updates every 5 seconds should be plenty often. This can always be increased to miss absolutely nothing, but its probably not worth the additional thread count.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TaskScheduler
public TaskScheduler(TournamentControl tournamentControl)
Schedules tasks.- Parameters:
tournamentControl
- The need tournament control.
-
-
Method Detail
-
outputLeaderboardToFile
public void outputLeaderboardToFile()
Writes the current results of the tournament into a html table and writes to "htmlLeaderboardFile". Runs asynchronously to not hinder further execution.
-
startRefresh
public void startRefresh()
Starts polling the data from the gameserver at a fixed rate (5000ms by default), updating the local data. Starts new games where possible.
-
stopRefresh
public void stopRefresh()
Stops any new polling of game data, while finishing up any remaining requests.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
Reacts to any PropertyChangeEvents that have been registered properly. Checks the state of the tournament execution when any previously running game is finished up. When the tournament is finished, this will stop any communication with the server and generate a finished html overview of the resutls- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
-