/** * @brief 异步redis query执行完成 * @param type $result * @param type $error */ public function ahaRedisCallback($result, $error) { $data = compact('result', 'error'); $generator = $this->_coroutineStack->pop(); $generator->send($data); //$this->run($generator); //通过这个方式调度 比起上面这种,可以让异步回调的调用方更快的得到控制权 进行资源回收 \Aha\Coroutine\Scheduler::getInstance()->asyncIoSchedule($this); }
/** * @brief 如果是运行在协程模式下 开启协程调度器 * @return type */ protected function _initScheduler() { $mode = $this->_objConfig->get('aha', 'mode'); if (empty($mode) || $mode !== 'coroutine') { $this->_objScheduler = null; return; } $this->_objScheduler = \Aha\Coroutine\Scheduler::getInstance(); }