You are here

private function EachPromise::refillPending in Auth0 Single Sign On 8.2

2 calls to EachPromise::refillPending()
EachPromise::promise in vendor/guzzlehttp/promises/src/EachPromise.php
Returns a promise.
EachPromise::step in vendor/guzzlehttp/promises/src/EachPromise.php

File

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

Class

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

Namespace

GuzzleHttp\Promise

Code

private function refillPending() {
  if (!$this->concurrency) {

    // Add all pending promises.
    while ($this
      ->addPending() && $this
      ->advanceIterator()) {
    }
    return;
  }

  // Add only up to N pending promises.
  $concurrency = is_callable($this->concurrency) ? call_user_func($this->concurrency, count($this->pending)) : $this->concurrency;
  $concurrency = max($concurrency - count($this->pending), 0);

  // Concurrency may be set to 0 to disallow new promises.
  if (!$concurrency) {
    return;
  }

  // Add the first pending promise.
  $this
    ->addPending();

  // Note this is special handling for concurrency=1 so that we do
  // not advance the iterator after adding the first promise. This
  // helps work around issues with generators that might not have the
  // next value to yield until promise callbacks are called.
  while (--$concurrency && $this
    ->advanceIterator() && $this
    ->addPending()) {
  }
}