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\PromiseCode
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);
}