src/Robo/Common/Executor.php
public function wait(callable $callable, array $args, $message = '') {
    $maxWait = 60 * 1000;
    $checkEvery = 1 * 1000;
    $start = microtime(TRUE) * 1000;
    $end = $start + $maxWait;

    if (!$message) {
      $method_name = is_array($callable) ? $callable[1] : $callable;
      $message = "Waiting for $method_name() to return true.";
    }

    // For some reason we can't reuse $start here.
    while (microtime(TRUE) * 1000 < $end) {
      $this->logger->info($message);
      try {
        if (call_user_func_array($callable, $args)) {
          return TRUE;
        }
      }
      catch (\Exception $e) {
        $this->logger->error($e->getMessage());
      }
      usleep($checkEvery * 1000);
    }

    throw new BltException("Timed out.");
  }
public function wait(callable $callable, array $args, $message = '') {
    $maxWait = 60 * 1000;
    $checkEvery = 1 * 1000;
    $start = microtime(TRUE) * 1000;
    $end = $start + $maxWait;

    if (!$message) {
      $method_name = is_array($callable) ? $callable[1] : $callable;
      $message = "Waiting for $method_name() to return true.";
    }

    // For some reason we can't reuse $start here.
    while (microtime(TRUE) * 1000 < $end) {
      $this->logger->info($message);
      try {
        if (call_user_func_array($callable, $args)) {
          return TRUE;
        }
      }
      catch (\Exception $e) {
        $this->logger->error($e->getMessage());
      }
      usleep($checkEvery * 1000);
    }

    throw new BltException("Timed out.");
  }
public function wait ( callable $ callable , array $ args , $ message = '' ) { $ maxWait = 60 * 1000 ; $ checkEvery = 1 * 1000 ; $ start = microtime ( TRUE ) * 1000 ; $ end = $ start + $ maxWait ; if ( ! $ message ) { $ method_name = is_array ( $ callable ) ? $ callable [ 1 ] : $ callable ; $ message = "Waiting for $method_name() to return true." ; } // For some reason we can't reuse $start here. while ( microtime ( TRUE ) * 1000 < $ end ) { $ this -> logger -> info ( $ message ) ; try { if ( call_user_func_array ( $ callable , $ args ) ) { return TRUE ; } } catch ( \ Exception $ e ) { $ this -> logger -> error ( $ e -> getMessage ( ) ) ; } usleep ( $ checkEvery * 1000 ) ; } throw new BltException ( "Timed out." ) ; }
Waits until a given callable returns TRUE.

This does have a maximum timeout.

@param callable $callable
The method/function to wait for a TRUE response from.
@param array $args
Arguments to pass to $callable.
@param string $message
The message to display when this function is called.

@return bool
TRUE if callable returns TRUE.

@throws \Exception
Waits until a given callable returns TRUE .