You are here

private function Promise::waitIfPending in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/promises/src/Promise.php \GuzzleHttp\Promise\Promise::waitIfPending()
1 call to Promise::waitIfPending()
Promise::wait in vendor/guzzlehttp/promises/src/Promise.php
Waits until the promise completes if possible.

File

vendor/guzzlehttp/promises/src/Promise.php, line 212

Class

Promise
Promises/A+ implementation that avoids recursion when possible.

Namespace

GuzzleHttp\Promise

Code

private function waitIfPending() {
  if ($this->state !== self::PENDING) {
    return;
  }
  elseif ($this->waitFn) {
    $this
      ->invokeWaitFn();
  }
  elseif ($this->waitList) {
    $this
      ->invokeWaitList();
  }
  else {

    // If there's not wait function, then reject the promise.
    $this
      ->reject('Cannot wait on a promise that has ' . 'no internal wait function. You must provide a wait ' . 'function when constructing the promise to be able to ' . 'wait on a promise.');
  }
  queue()
    ->run();
  if ($this->state === self::PENDING) {
    $this
      ->reject('Invoking the wait callback did not resolve the promise');
  }
}