Hprose\Socket\Transporter::loop PHP Метод

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

public loop ( )
    public function loop()
    {
        $client = $this->client;
        while (count($this->results) > 0) {
            $pool = $this->createPool($client, $this);
            if ($pool === false) {
                continue;
            }
            $o = new stdClass();
            $o->current = 0;
            $o->count = count($this->results);
            $o->responses = array();
            $o->requests = array();
            $o->readpool = array();
            $o->writepool = $pool;
            $o->buffers = $this->buffers;
            $o->deadlines = $this->deadlines;
            $o->results = $this->results;
            $this->buffers = array();
            $this->deadlines = array();
            $this->results = array();
            while (count($o->results) > 0) {
                $read = array_values($o->readpool);
                $write = array_values($o->writepool);
                $except = null;
                $timeout = max(0, min($o->deadlines) - microtime(true));
                $tv_sec = floor($timeout);
                $tv_usec = ($timeout - $tv_sec) * 1000;
                $n = @stream_select($read, $write, $except, $tv_sec, $tv_usec);
                if ($n === false) {
                    $e = $this->getLastError('unkown io error.');
                    foreach ($o->results as $result) {
                        $result->reject($e);
                    }
                    $o->results = array();
                }
                if ($n > 0) {
                    foreach ($write as $stream) {
                        $this->asyncWrite($stream, $o);
                    }
                    foreach ($read as $stream) {
                        $this->asyncRead($stream, $o);
                    }
                }
                $this->checkTimeout($o);
                if (count($o->results) > 0 && count($o->readpool) + count($o->writepool) === 0) {
                    $o->writepool = $this->createPool($client, $o);
                }
            }
            foreach ($o->writepool as $stream) {
                @fclose($stream);
            }
            foreach ($o->readpool as $stream) {
                @fclose($stream);
            }
        }
    }