TaskScheduler: get rid of cancelTask()

developers should be using TaskHandler->cancel() instead.
This commit is contained in:
Dylan K. Taylor 2020-07-08 11:49:43 +01:00
parent da798817b5
commit a71b111b50

View File

@ -72,19 +72,9 @@ class TaskScheduler{
return $this->addTask($task, $delay, $period);
}
public function cancelTask(int $taskId) : void{
if(isset($this->tasks[$taskId])){
try{
$this->tasks[$taskId]->cancel();
}finally{
unset($this->tasks[$taskId]);
}
}
}
public function cancelAllTasks() : void{
foreach($this->tasks as $id => $task){
$this->cancelTask($id);
$task->cancel();
}
$this->tasks = [];
while(!$this->queue->isEmpty()){