azure-storage-common/src/Common/Internal/ServiceRestProxy.php
protected function sendConcurrentAsync(
        callable $generator,
        $statusCode,
        ServiceOptions $options
    ) {
        $client = $this->client;
        $middlewareStack = $this->createMiddlewareStack($options);

        $sendAsync = function ($request, $options) use ($client) {
            if ($request->getMethod() == 'HEAD') {
                $options['decode_content'] = false;
            }
            return $client->sendAsync($request, $options);
        };

        $handler = $middlewareStack->apply($sendAsync);

        $requestOptions = $this->generateRequestOptions($options, $handler);

        $promises = \call_user_func(
            function () use (
                $generator,
                $handler,
                $requestOptions
            ) {
                while (is_callable($generator) && ($request = $generator())) {
                    yield \call_user_func($handler, $request, $requestOptions);
                }
            }
        );

        $eachPromise = new EachPromise($promises, [
            'concurrency' => $options->getNumberOfConcurrency(),
            'fulfilled' => function ($response, $index) use ($statusCode) {
                //the promise is fulfilled, evaluate the response
                self::throwIfError(
                    $response,
                    $statusCode
                );
            },
            'rejected' => function ($reason, $index) {
                //Still rejected even if the retry logic has been applied.
                //Throwing exception.
                throw $reason;
            }
        ]);

        return $eachPromise->promise();
    }
protected function sendConcurrentAsync(
        callable $generator,
        $statusCode,
        ServiceOptions $options
    ) {
        $client = $this->client;
        $middlewareStack = $this->createMiddlewareStack($options);

        $sendAsync = function ($request, $options) use ($client) {
            if ($request->getMethod() == 'HEAD') {
                $options['decode_content'] = false;
            }
            return $client->sendAsync($request, $options);
        };

        $handler = $middlewareStack->apply($sendAsync);

        $requestOptions = $this->generateRequestOptions($options, $handler);

        $promises = \call_user_func(
            function () use (
                $generator,
                $handler,
                $requestOptions
            ) {
                while (is_callable($generator) && ($request = $generator())) {
                    yield \call_user_func($handler, $request, $requestOptions);
                }
            }
        );

        $eachPromise = new EachPromise($promises, [
            'concurrency' => $options->getNumberOfConcurrency(),
            'fulfilled' => function ($response, $index) use ($statusCode) {
                //the promise is fulfilled, evaluate the response
                self::throwIfError(
                    $response,
                    $statusCode
                );
            },
            'rejected' => function ($reason, $index) {
                //Still rejected even if the retry logic has been applied.
                //Throwing exception.
                throw $reason;
            }
        ]);

        return $eachPromise->promise();
    }
Send the requests concurrently. Number of concurrency can be modified
by inserting a new key/value pair with the key 'number_of_concurrency'
into the $requestOptions of $serviceOptions. Return only the promise.

@param  callable       $generator   the generator function to generate
request upon fulfillment
@param  int            $statusCode  The expected status code for each of the
request generated by generator.
@param  ServiceOptions $options     The service options for the concurrent
requests.

@return \GuzzleHttp\Promise\Promise|\GuzzleHttp\Promise\PromiseInterface