Пример #1
0
 private function poll()
 {
     $links = [];
     foreach ($this->active as $link) {
         $links[] = $link;
     }
     list($read, $error) = $this->driver->poll($links);
     foreach ($error as $link) {
         $query = $this->active[$link];
         $err = $this->driver->error($link);
         $this->free($link);
         $query->reject($err);
     }
     foreach ($read as $link) {
         $query = $this->active[$link];
         try {
             $result = $this->driver->read($link);
         } catch (\Exception $err) {
             $this->free($link);
             $query->reject($err);
             continue;
         }
         $this->free($link);
         $subquery = $query->resolve($result);
         if ($subquery instanceof Query) {
             $this->execQuery($subquery);
         } elseif ($subquery instanceof \Iterator) {
             $this->execIterator($subquery);
         }
     }
 }