Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EachPromise.php

function EachPromise::createPromise

1 call to EachPromise::createPromise()
EachPromise::promise in vendor/guzzlehttp/promises/src/EachPromise.php
@psalm-suppress InvalidNullableReturnType

File

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

Class

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

Namespace

GuzzleHttp\Promise

Code

private function createPromise() : void {
    $this->mutex = false;
    $this->aggregate = new Promise(function () : void {
        if ($this->checkIfFinished()) {
            return;
        }
        reset($this->pending);
        // Consume a potentially fluctuating list of promises while
        // ensuring that indexes are maintained (precluding array_shift).
        while ($promise = current($this->pending)) {
            next($this->pending);
            $promise->wait();
            if (Is::settled($this->aggregate)) {
                return;
            }
        }
    });
    // Clear the references when the promise is resolved.
    $clearFn = function () : void {
        $this->iterable = $this->concurrency = $this->pending = null;
        $this->onFulfilled = $this->onRejected = null;
        $this->nextPendingIndex = 0;
    };
    $this->aggregate
        ->then($clearFn, $clearFn);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal