pocketmine\scheduler\AsyncPool::removeTasks PHP Method

removeTasks() public method

public removeTasks ( )
    public function removeTasks()
    {
        do {
            foreach ($this->tasks as $task) {
                $task->cancelRun();
                $this->removeTask($task);
            }
            if (count($this->tasks) > 0) {
                Server::microSleep(25000);
            }
        } while (count($this->tasks) > 0);
        for ($i = 0; $i < $this->size; ++$i) {
            $this->workerUsage[$i] = 0;
        }
        $this->taskWorkers = [];
        $this->tasks = [];
    }

Usage Example

 public function cancelAllTasks()
 {
     foreach ($this->tasks as $task) {
         $task->cancel();
     }
     $this->tasks = [];
     $this->asyncPool->removeTasks();
     $this->queue = new ReversePriorityQueue();
     $this->ids = 1;
 }
All Usage Examples Of pocketmine\scheduler\AsyncPool::removeTasks