Fix ScheduledTask timer.

This commit is contained in:
Major-
2015-08-27 23:29:27 +01:00
parent bbde7fd9e8
commit 0a3574eb20
@@ -28,8 +28,7 @@ public abstract class ScheduledTask {
* Creates a new scheduled task.
*
* @param delay The delay between executions of the task, in pulses.
* @param immediate A flag indicating if this task should (for the first execution) be ran immediately, or after the
* {@code delay}.
* @param immediate Indicates whether or not this task should be executed immediately, or after the {@code delay}.
* @throws IllegalArgumentException If the delay is less than or equal to zero.
*/
public ScheduledTask(int delay, boolean immediate) {
@@ -37,11 +36,6 @@ public abstract class ScheduledTask {
pulses = immediate ? 0 : delay;
}
/**
* Executes this task.
*/
public abstract void execute();
/**
* Checks if this task is running.
*
@@ -51,16 +45,6 @@ public abstract class ScheduledTask {
return running;
}
/**
* Pulses this task: updates the delay and calls {@link #execute()} if necessary.
*/
final void pulse() {
if (running && pulses-- == 0) {
execute();
pulses = delay;
}
}
/**
* Sets the delay.
*
@@ -79,4 +63,19 @@ public abstract class ScheduledTask {
running = false;
}
/**
* Executes this task.
*/
public abstract void execute();
/**
* Pulses this task: updates the delay and calls {@link #execute()} if necessary.
*/
final void pulse() {
if (running && --pulses <= 0) {
execute();
pulses = delay;
}
}
}