Kraken\Loop\Model\SelectLoop::start PHP Метод

start() публичный Метод

public start ( )
    public function start()
    {
        if ($this->flowController->isRunning) {
            return;
        }
        // TODO KRF-107
        $this->addPeriodicTimer(1, function () {
            usleep(1);
        });
        $this->flowController->isRunning = true;
        $this->startTickQueue->tick();
        while ($this->flowController->isRunning) {
            $this->nextTickQueue->tick();
            $this->futureTickQueue->tick();
            $this->timers->tick();
            // Next-tick or future-tick queues have pending callbacks ...
            if (!$this->flowController->isRunning || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
                $timeout = 0;
            } else {
                if ($scheduledAt = $this->timers->getFirst()) {
                    $timeout = $scheduledAt - $this->timers->getTime();
                    $timeout = $timeout < 0 ? 0 : $timeout * self::MICROSECONDS_PER_SECOND;
                } else {
                    if ($this->readStreams || $this->writeStreams) {
                        $timeout = null;
                    } else {
                        break;
                    }
                }
            }
            $this->waitForStreamActivity($timeout);
        }
    }