taskProxyData = $taskProxyData; $this->id = $id; $profileName = $taskProxyData['message']['task_name'] . '::' . $taskProxyData['message']['task_fuc_name']; $this->requestId = $this->getContext()->getLogId(); $this->getContext()->getLog()->profileStart($profileName); getInstance()->scheduler->IOCallBack[$this->requestId][] = $this; $keys = array_keys(getInstance()->scheduler->IOCallBack[$this->requestId]); $this->ioBackKey = array_pop($keys); $this->send(function ($serv, $taskId, $data) use ($profileName) { if ($this->isBreak) { return; } if (empty(getInstance()->scheduler->taskMap[$this->requestId])) { return; } $this->getContext()->getLog()->profileEnd($profileName); $this->result = $data; $this->ioBack = true; $this->nextRun(); }); } /** * 投递异步任务给Tasker进程 * * @param callable $callback 任务完成后的回调函数 * @return $this */ public function send($callback) { getInstance()->server->task($this->taskProxyData, $this->id, $callback); return $this; } /** * 销毁 */ public function destroy() { parent::destroy(); } }