protected static function _wrap($coroutine) { $taskId = self::newTaskId(); $coroutine = (function ($taskId, $coroutine) { $resp = (yield from $coroutine); \Coroutine::unregister($taskId); })($taskId, $coroutine); self::register($taskId, $coroutine); return $coroutine; }
public function multiCoroutine($taskId, $coroutine) { try { $resp = (yield from $coroutine); $this->_callRsp[] = $resp; if (count($this->_callRsp) == count($this->_callList)) { $this->executeCoroutine($this->_callRsp); $this->next(); } \Coroutine::unregister($taskId); } catch (\Exception $e) { $this->executeCoroutine(null, $e); $this->next(); } }