mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 08:49:42 +00:00
TaskScheduler: get rid of cancelTask()
developers should be using TaskHandler->cancel() instead.
This commit is contained in:
parent
da798817b5
commit
a71b111b50
@ -72,19 +72,9 @@ class TaskScheduler{
|
|||||||
return $this->addTask($task, $delay, $period);
|
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{
|
public function cancelAllTasks() : void{
|
||||||
foreach($this->tasks as $id => $task){
|
foreach($this->tasks as $id => $task){
|
||||||
$this->cancelTask($id);
|
$task->cancel();
|
||||||
}
|
}
|
||||||
$this->tasks = [];
|
$this->tasks = [];
|
||||||
while(!$this->queue->isEmpty()){
|
while(!$this->queue->isEmpty()){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user