static function flatMap(\CharlotteDunois\Phoebe\Pool $pool, array $array, callable $function) {
        $promises = array();
        
        $howMany = (int) \ceil((\count($array) / $pool->getSize()));
        $chunks = \array_chunk($array, $howMany);
        
        $newFun = function ($value) use ($function) {
            return \array_reduce($value, $function, array()); // @codeCoverageIgnore
        };
        
        foreach($chunks as $arg) {
            $promises[] = static::parallelize($pool, $newFun, array($arg))->then(null, function (\Throwable $e) {
                return $e;
            });
        }
        
        return \React\Promise\all($promises)->then(function (array $result) use ($function) {
            return \array_reduce(static::convertResult($result), $function, array());
        });
    }
static function flatMap(\CharlotteDunois\Phoebe\Pool $pool, array $array, callable $function) {
        $promises = array();
        
        $howMany = (int) \ceil((\count($array) / $pool->getSize()));
        $chunks = \array_chunk($array, $howMany);
        
        $newFun = function ($value) use ($function) {
            return \array_reduce($value, $function, array()); // @codeCoverageIgnore
        };
        
        foreach($chunks as $arg) {
            $promises[] = static::parallelize($pool, $newFun, array($arg))->then(null, function (\Throwable $e) {
                return $e;
            });
        }
        
        return \React\Promise\all($promises)->then(function (array $result) use ($function) {
            return \array_reduce(static::convertResult($result), $function, array());
        });
    }
static function flatMap ( \ CharlotteDunois \ Phoebe \ Pool $ pool , array $ array , callable $ function ) { $ promises = array ( ) ; $ howMany = ( int ) \ ceil ( ( \ count ( $ array ) / $ pool -> getSize ( ) ) ) ; $ chunks = \ array_chunk ( $ array , $ howMany ) ; $ newFun = function ( $ value ) use ( $ function ) { return \ array_reduce ( $ value , $ function , array ( ) ) ; // @codeCoverageIgnore } ; foreach ( $ chunks as $ arg ) { $ promises [ ] = static :: parallelize ( $ pool , $ newFun , array ( $ arg ) ) -> then ( null , function ( \ Throwable $ e ) { return $ e ; } ) ; } return \ React \ Promise \ all ( $ promises ) -> then ( function ( array $ result ) use ( $ function ) { return \ array_reduce ( static :: convertResult ( $ result ) , $ function , array ( ) ) ; } ) ; }
Parallelizes a given flattening function across a number of available workers, collects their return values and flattens the final array.
Whether the resulting array is an actual flat map depends on the given callable.

Internally this method makes use of `AsyncTask`s. The pool schedules the tasks across the workers automatically.
@param \CharlotteDunois\Phoebe\Pool  $pool
@param array                         $array     Must be serializable.
@param callable                      $function  Flattens the array.
@return \React\Promise\PromiseInterface
@throws \CharlotteDunois\Phoebe\MultiReasonException  The exception the promise gets rejected with.
Parallelizes a given flattening function across a number of available workers collects their return values and flattens the final array . Whether the resulting array is an actual flat map depends on the given callable .