获取一个task
@param $task
@param Child $parent
@return mixed|null|TaskProxy
@throws SwooleException
762271
public function task($task, Child $parent = null)
    {
        if (empty($task)) {
            return null;
        }
        if (class_exists($task)) {
            $task_class = $task;
        } else {
            $task = str_replace('/', '\\', $task);
            $task_class = "app\\Tasks\\" . $task;
            if (!class_exists($task_class)) {
                $task_class = "Server\\Tasks\\" . $task;
                if (!class_exists($task_class)) {
                    throw new SwooleException("class task_class not exists");
                }
            }
        }
        if (!get_instance()->server->taskworker) {//工作进程返回taskproxy
            $this->_task_proxy->core_name = $task_class;
            if ($parent != null) {
                $this->_task_proxy->setContext($parent->getContext());
            }
            return AOP::getAOP($this->_task_proxy);
        }
        $task_instance = Pool::getInstance()->get($task_class);
        $task_instance->reUse();
        return $task_instance;
    }
428274
private function send(Task $task): \Generator
    {
        yield from $this->context->send($task);
        return yield from $this->context->receive();
    }
295272
public function run(Task $task, Closure $callback = null)
    {
        $processes = [];

        $callback = $callback ?: function () {
        };

        // Here we will gather all the process instances by host. We will build them in
        // an array so we can easily loop through them then start them up. We'll key
        // the array by the target name and set the value as the process instance.
        foreach ($task->hosts as $host) {
            $process = $this->getProcess($host, $task);

            $processes[$process[0]] = $process[1];
        }

        // Next we'll loop through the processes and run them sequentially while taking
        // the output and feeding it through the callback. This will in turn display
        // the output back out to the screen for the developer to inspect closely.
        foreach ($processes as $host => $process) {
            $process->run(function ($type, $output) use ($host, $callback) {
                $callback($type, $host, $output);
            });
        }

        return $this->gatherExitCodes($processes);
    }
78418
public function handleGetChildren($parent)
	{
		$this->setDataSource(
			call_user_func($this->tree_view_children_callback, $parent)
		);

		if ($this->getPresenter()->isAjax()) {
			$this->getPresenter()->payload->_datagrid_url = $this->refresh_url;
			$this->getPresenter()->payload->_datagrid_tree = $parent;

			$this->redrawControl('items');

			$this->onRedraw();
		} else {
			$this->getPresenter()->redirect('this');
		}
	}
824524
public function setTask(Task $task = null)
    {
        $this->task = $task;
        if (null !== $task) {
            $task->addComment($this);
        }

        return $this;
    }
677170
private void processChildTasks(Task parentTask) throws SQLException
   {
      List<Row> rows = getRows("select * from zscheduleitem where zparentactivity_=? and z_ent=? order by zorderinparentactivity", parentTask.getUniqueID(), m_entityMap.get("Activity"));
      for (Row row : rows)
      {
         Task task = parentTask.addTask();
         populateTask(row, task);
         processChildTasks(task);
      }
   }
605219
public function registerTask($task, $method)
	{
		if (in_array(strtolower($method), $this->_taskMap))
		{
			$this->_taskMap[strtolower($task)] = $method;
		}

		return $this;
	}
1206631
public function work($task)
    {
        foreach ($this as $worker) {
            if ($worker->canWork($task)) {
                $workerReport = $worker->work($task);
                if ($workerReport->isSuccessful()) {
                    return $workerReport;
                }
            }
        }

        return $this->getFactory()->createNoAbleWorkersReport();
    }
395686
public function execute(AbstractTask $task, $parameters = array()) {

        $this->task = $task;

        $this->loadHtml($this->obtainHtml($parameters));

        $ignore_rules = $task->getIgnoreRules();

        foreach ($ignore_rules as $rule) {
            $this->useIgnoreRule($rule);
        }

        $class = $task->getClassName();

        $entity = new $class;

        $task->setEntity($entity);

        $rules = $task->getParseRules();

        foreach ($rules as $rule) {
            $this->useParseRule($rule, $entity);
        }
        return $entity;
    }
1276265
public static function create(Task $task, $name, $weight = 1, $backup = false, \Closure $work = null)
    {
        return new self($task, $name, $weight, $backup, $work);
    }
1119418
public function appChild(&$parent, $child, $msg = '')
    {
        if (empty($parent)) {
            throw new Exception($msg);
        }
        if (! empty($child)) {
            $parent->appendChild($child);
        }
    }
579108
public function run(Task $task, Closure $callback = null)
    {
        $processes = [];

        $callback = $callback ?: function () {
        };

        // Here we will gather all the process instances by host. We will build them in
        // an array so we can easily loop through them then start them up. We'll key
        // the array by the target name and set the value as the process instance.
        foreach ($task->hosts as $host) {
            $process = $this->getProcess($host, $task);

            $processes[$process[0]] = $process[1];
        }

        // Next we will start all of the processes, but we won't block. Instead we will
        // gather all of the output incrementally from each of the processes as they
        // stay running on a machine. We'll check to see if any are still running.
        $this->startProcesses($processes);

        while ($this->areRunning($processes)) {
            $this->gatherOutput($processes, $callback);
        }

        // Finally, we'll gather the output one last time to make sure no more output is
        // sitting on the buffer. Then we'll gather the cumulative exit code just to
        // see if we need to run the after even for the task or if we skip it out.
        $this->gatherOutput($processes, $callback);

        return $this->gatherExitCodes($processes);
    }
629431
public function task(\swoole\Server $serv, $task_id, $src_worker_id, $data) {
        $result = null;
        Debug::start(false);
        try{
            $do = $data[0];
            $args = $data[1];
            $class = $do[0];
            $class = new $class($serv,$task_id,$src_worker_id);
            $func = $do[1];
            $result = call_user_func_array([$class,$func],$args);
        }
        catch (\Exception $e) {
            Debug::exception($e);
        }
        Debug::end();
        Pool::destroy();
        return $result;
    }
852480
private void writeTask(Task task) throws IOException
   {
      writeFields(null, task, TaskField.values());
      for (Task child : task.getChildTasks())
      {
         writeTask(child);
      }
   }
1128988
public static function record_from_adhoc_task($task) {
        $record = new \stdClass();
        $record->classname = self::get_canonical_class_name($task);
        $record->id = $task->get_id();
        $record->component = $task->get_component();
        $record->blocking = $task->is_blocking();
        $record->nextruntime = $task->get_next_run_time();
        $record->faildelay = $task->get_fail_delay();
        $record->customdata = $task->get_custom_data_as_string();
        $record->userid = $task->get_userid();

        return $record;
    }
423651
public static function isBeneath(string $child, string $parent)
    {
        if ((strlen($child) >= strlen($parent))
            && strpos($child, $parent) === 0) {
                return true;
        }

        return false;
    }
82458
protected function _constructStringParentStringChild($parent, $child = null)
    {
        // obtain ref to the filesystem layer
        $fs = FileSystem::getFileSystem();

        if ($child === null) {
            throw new NullPointerException("Argument to function must not be null");
        }
        if ($parent !== null) {
            if ($parent === "") {
                $this->path = $fs->resolve($fs->getDefaultParent(), $fs->normalize($child));
            } else {
                $this->path = $fs->resolve($fs->normalize($parent), $fs->normalize($child));
            }
        } else {
            $this->path = (string) $fs->normalize($child);
        }
        $this->prefixLength = (int) $fs->prefixLength($this->path);
    }