Example #1
0
File: Pool.php Project: mpyw/co
 /**
  * Run curl_multi_exec() loop.
  */
 public function wait()
 {
     curl_multi_exec($this->mh, $active);
     // Start requests.
     do {
         // if cURL handle is running, use curl_multi_select()
         // otherwise, just sleep until nearest time
         $this->scheduler->isEmpty() ? $this->delayer->sleep() : curl_multi_select($this->mh, $this->options['interval']) < 0 && usleep($this->options['interval'] * 1000000);
         curl_multi_exec($this->mh, $active);
         $this->scheduler->consume();
         $this->delayer->consume();
     } while (!$this->haltException && (!$this->scheduler->isEmpty() || !$this->delayer->isEmpty()));
     if ($this->haltException) {
         throw $this->haltException;
     }
 }