From 95787c2be912f80200331b556dde386e517a8f1b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 21 Jun 2018 12:49:08 +0100 Subject: [PATCH] TaskScheduler: fixed tasks not getting destroyed when all tasks in scheduler are cancelled before next heartbeat they got removed from the tasks array, but not from the queue (for performance reasons). The queue gets cleaned up by the heartbeat, but it was checking if there were things in the main array, not in the queue. There are a couple of other bugs with cancelling tasks that this doesn't fix that are rather more complicated to deal with. --- src/pocketmine/scheduler/TaskScheduler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/scheduler/TaskScheduler.php b/src/pocketmine/scheduler/TaskScheduler.php index a641aa292..2c23cb317 100644 --- a/src/pocketmine/scheduler/TaskScheduler.php +++ b/src/pocketmine/scheduler/TaskScheduler.php @@ -222,7 +222,7 @@ class TaskScheduler{ } private function isReady(int $currentTick) : bool{ - return count($this->tasks) > 0 and $this->queue->current()->getNextRun() <= $currentTick; + return !$this->queue->isEmpty() and $this->queue->current()->getNextRun() <= $currentTick; } /**