workerman select run 方法为何这样实现

meows

Events\Select.php文件中最后处理同步进程信号 pcntl_signal_dispatch();

运行优先级如下:

  1. 如果有定时任务业务,最先运行
  2. 如果有客户端读写数据,其次运行
  3. 最后才是处理信号逻辑

疑问:这样的执行顺序,为了status 命令去查看是否有业务阻塞?

     if (!$this->scheduler->isEmpty()) {
                $this->tick();
            }

            foreach ($read as $fd) {
                $fdKey = (int)$fd;
                if (isset($this->readEvents[$fdKey])) {
                    $this->readEvents[$fdKey]($fd);
                }
            }

            foreach ($write as $fd) {
                $fdKey = (int)$fd;
                if (isset($this->writeEvents[$fdKey])) {
                    $this->writeEvents[$fdKey]($fd);
                }
            }

            foreach ($except as $fd) {
                $fdKey = (int)$fd;
                if (isset($this->exceptEvents[$fdKey])) {
                    $this->exceptEvents[$fdKey]($fd);
                }
            }

            if (!empty($this->signalEvents)) {
                // Calls signal handlers for pending signals
                pcntl_signal_dispatch();
            }
613 1 0
1个回答

nitron

业务系统必然业务优先.

  1. 保证定时任务的"足够"准时
  2. 保证业务处理响应足够快速
年代过于久远,无法发表回答
×
🔝