Cml\Vendor\PhpThread::run PHP Method

run() public method

执行线程队列里的所有任务
public run ( ) : array
return array
    public function run()
    {
        // 初始化
        reset($this->queue);
        for ($i = 0; $i < $this->max; $i++) {
            if ($this->makeTask() == -1) {
                break;
            }
        }
        // 处理任务队列
        reset($this->tasks);
        while (count($this->tasks) > 0) {
            $task = current($this->tasks);
            $this->processTask($task);
            if ($task['status'] == -1 || $task['status'] == 2) {
                if ($this->saveSuccess) {
                    $this->success[] = $task;
                }
                unset($this->tasks[key($this->tasks)]);
                $this->makeTask();
            } else {
                $this->tasks[key($this->tasks)] = $task;
            }
            if (!next($this->tasks)) {
                reset($this->tasks);
            }
        }
        return $this->getSuccessInfo();
    }