diff --git a/src/org/apollo/game/scheduling/Scheduler.java b/src/org/apollo/game/scheduling/Scheduler.java index 725eceee..b3302077 100644 --- a/src/org/apollo/game/scheduling/Scheduler.java +++ b/src/org/apollo/game/scheduling/Scheduler.java @@ -16,25 +16,26 @@ import org.apollo.util.CollectionUtil; public final class Scheduler { /** - * An {@link ArrayDeque} of tasks that are pending execution. + * The Queue of tasks that are pending execution. */ - private final Queue pendingTasks = new ArrayDeque<>(); + private final Queue pending = new ArrayDeque<>(); /** - * An {@link ArrayList} of currently active tasks. + * The List of currently active tasks. */ - private final List tasks = new ArrayList<>(); + private final List active = new ArrayList<>(); /** - * Called every pulse: executes tasks that are still pending, adds new tasks and stops old tasks. + * Pulses the {@link Queue} of {@link ScheduledTask}s, removing those that are no longer running. */ public void pulse() { - CollectionUtil.pollAll(pendingTasks, tasks::add); + CollectionUtil.pollAll(pending, active::add); - for (Iterator iterator = tasks.iterator(); iterator.hasNext();) { + for (Iterator iterator = active.iterator(); iterator.hasNext();) { ScheduledTask task = iterator.next(); task.pulse(); - if (task.isRunning()) { + + if (!task.isRunning()) { iterator.remove(); } } @@ -47,7 +48,7 @@ public final class Scheduler { * @return {@code true} if the task was added successfully. */ public boolean schedule(ScheduledTask task) { - return pendingTasks.add(task); + return pending.add(task); } } \ No newline at end of file