diff --git a/src/Foundation/Client.php b/src/Foundation/Client.php index ba6af28..05a2344 100644 --- a/src/Foundation/Client.php +++ b/src/Foundation/Client.php @@ -76,6 +76,7 @@ public function sendAsync(Message $message): PromiseInterface /** * @see https://docs.guzzlephp.org/en/stable/quickstart.html#concurrent-requests + * @see \GuzzleHttp\Pool * * @param iterable $messages * @@ -86,13 +87,14 @@ public function sendAsync(Message $message): PromiseInterface */ public function pool(iterable $messages): array { - $promises = []; - - foreach ($messages as $key => $message) { - $promises[$key] = $this->sendAsync($message); - } - // return Utils::settle($promises)->wait(); - return Utils::unwrap($promises); + /** @noinspection PhpParamsInspection */ + return Utils::unwrap( + (function (iterable $messages): \Generator { + foreach ($messages as $key => $message) { + yield $key => $this->sendAsync($message); + } + })($messages) + ); } }