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.
This commit is contained in:
Dylan K. Taylor 2018-06-21 12:49:08 +01:00
parent 7b7be9618c
commit 95787c2be9

View File

@ -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;
}
/**