protected function read()
    {
        $n = 0;
        while ($info = curl_multi_info_read($this->mh)) {
            $n++;
            $request = $this->queue[(int)$info['handle']];
            $result = $info['result'];

            curl_multi_remove_handle($this->mh, $request->getHandle());
            unset($this->running[$request->getUID()]);
            $this->detach($request);

            $event = new Event();
            $event->request = $request;
            $event->response = new Response($request, curl_multi_getcontent($request->getHandle()));
            if ($result !== CURLE_OK) {
                $event->response->setError(new Error(curl_error($request->getHandle()), $result));
            }
            $event->queue = $this;
            $this->dispatch('complete', $event);
            $request->dispatch('complete', $event);
        }

        return $n;
    }
protected function read()
    {
        $n = 0;
        while ($info = curl_multi_info_read($this->mh)) {
            $n++;
            $request = $this->queue[(int)$info['handle']];
            $result = $info['result'];

            curl_multi_remove_handle($this->mh, $request->getHandle());
            unset($this->running[$request->getUID()]);
            $this->detach($request);

            $event = new Event();
            $event->request = $request;
            $event->response = new Response($request, curl_multi_getcontent($request->getHandle()));
            if ($result !== CURLE_OK) {
                $event->response->setError(new Error(curl_error($request->getHandle()), $result));
            }
            $event->queue = $this;
            $this->dispatch('complete', $event);
            $request->dispatch('complete', $event);
        }

        return $n;
    }
protected function read ( ) { $ n = 0 ; while ( $ info = curl_multi_info_read ( $ this -> mh ) ) { $ n ++ ; $ request = $ this -> queue [ ( int ) $ info [ 'handle' ] ] ; $ result = $ info [ 'result' ] ; curl_multi_remove_handle ( $ this -> mh , $ request -> getHandle ( ) ) ; unset ( $ this -> running [ $ request -> getUID ( ) ] ) ; $ this -> detach ( $ request ) ; $ event = new Event ( ) ; $ event -> request = $ request ; $ event -> response = new Response ( $ request , curl_multi_getcontent ( $ request -> getHandle ( ) ) ) ; if ( $ result !== CURLE_OK ) { $ event -> response -> setError ( new Error ( curl_error ( $ request -> getHandle ( ) ) , $ result ) ) ; } $ event -> queue = $ this ; $ this -> dispatch ( 'complete' , $ event ) ; $ request -> dispatch ( 'complete' , $ event ) ; } return $ n ; }
Processes handles which are ready and removes them from pool.

@return int Amount of requests completed
Processes handles which are ready and removes them from pool .