original_string: private function wait()
      {
          do {
              if (empty($this->queries)) {
                  break;
              }
              $links = $errors = $reject = [];
              foreach ($this->queries as $link) {
                  $links[] = $errors[] = $reject[] = $link['l'];
              }
              if (!mysqli_poll($links, $errors, $reject, self::$sleep, self::$usleep)) {
                  continue;
              }
              foreach ($this->queries as $l => $link) {
                  $promise = $this->getPromise($link);
                  $cnx    = $this->getConnection($link);
                  try {
                      $result = $cnx->reap_async_query();
                      if ($result instanceof mysqli_result) {
                          $promise->resolve($result);
                      } else {
                          $errNo = mysqli_errno($cnx);
                          $errStr = mysqli_error($cnx);
                          if (0 !== $errNo || 0 !== strlen($errStr)) {
                              throw new mysqli_sql_exception($errStr, $errNo);
                          } else {
                              $promise->resolve($cnx);
                          }
                      }
                  } catch (mysqli_sql_exception $e) {
                      $promise->reject($e);
                  }
                  $this->processed++;
                  unset($this->queries[$l]);
              }
          } while ($this->processed < count($this->queries));
          $this->reset();
      }
code: private function wait()
      {
          do {
              if (empty($this->queries)) {
                  break;
              }
              $links = $errors = $reject = [];
              foreach ($this->queries as $link) {
                  $links[] = $errors[] = $reject[] = $link['l'];
              }
              if (!mysqli_poll($links, $errors, $reject, self::$sleep, self::$usleep)) {
                  continue;
              }
              foreach ($this->queries as $l => $link) {
                  $promise = $this->getPromise($link);
                  $cnx    = $this->getConnection($link);
                  try {
                      $result = $cnx->reap_async_query();
                      if ($result instanceof mysqli_result) {
                          $promise->resolve($result);
                      } else {
                          $errNo = mysqli_errno($cnx);
                          $errStr = mysqli_error($cnx);
                          if (0 !== $errNo || 0 !== strlen($errStr)) {
                              throw new mysqli_sql_exception($errStr, $errNo);
                          } else {
                              $promise->resolve($cnx);
                          }
                      }
                  } catch (mysqli_sql_exception $e) {
                      $promise->reject($e);
                  }
                  $this->processed++;
                  unset($this->queries[$l]);
              }
          } while ($this->processed < count($this->queries));
          $this->reset();
      }
code_tokens: private function wait ( ) { do { if ( empty ( $ this -> queries ) ) { break ; } $ links = $ errors = $ reject = [ ] ; foreach ( $ this -> queries as $ link ) { $ links [ ] = $ errors [ ] = $ reject [ ] = $ link [ 'l' ] ; } if ( ! mysqli_poll ( $ links , $ errors , $ reject , self :: $ sleep , self :: $ usleep ) ) { continue ; } foreach ( $ this -> queries as $ l => $ link ) { $ promise = $ this -> getPromise ( $ link ) ; $ cnx = $ this -> getConnection ( $ link ) ; try { $ result = $ cnx -> reap_async_query ( ) ; if ( $ result instanceof mysqli_result ) { $ promise -> resolve ( $ result ) ; } else { $ errNo = mysqli_errno ( $ cnx ) ; $ errStr = mysqli_error ( $ cnx ) ; if ( 0 !== $ errNo || 0 !== strlen ( $ errStr ) ) { throw new mysqli_sql_exception ( $ errStr , $ errNo ) ; } else { $ promise -> resolve ( $ cnx ) ; } } } catch ( mysqli_sql_exception $ e ) { $ promise -> reject ( $ e ) ; } $ this -> processed ++ ; unset ( $ this -> queries [ $ l ] ) ; } } while ( $ this -> processed < count ( $ this -> queries ) ) ; $ this -> reset ( ) ; }
docstring: Wait for pending queries to complete.
docstring_tokens: Wait for pending queries to complete .