You are here

private function EachPromise::step in Lockr 7.3

1 call to EachPromise::step()
EachPromise::addPending in vendor/guzzlehttp/promises/src/EachPromise.php

File

vendor/guzzlehttp/promises/src/EachPromise.php, line 201

Class

EachPromise
Represents a promise that iterates over many promises and invokes side-effect functions in the process.

Namespace

GuzzleHttp\Promise

Code

private function step($idx) {

  // If the promise was already resolved, then ignore this step.
  if ($this->aggregate
    ->getState() !== PromiseInterface::PENDING) {
    return;
  }
  unset($this->pending[$idx]);

  // Only refill pending promises if we are not locked, preventing the
  // EachPromise to recursively invoke the provided iterator, which
  // cause a fatal error: "Cannot resume an already running generator"
  if ($this
    ->advanceIterator() && !$this
    ->checkIfFinished()) {

    // Add more pending promises if possible.
    $this
      ->refillPending();
  }
}