static function filter(\CharlotteDunois\Phoebe\Pool $pool, array $array, ?callable $function = null) {
        if($function === null) {
            $function = function ($value) {
                return ((bool) $value); // @codeCoverageIgnore
            };
        }
        
        $promises = array();
        
        foreach($array as $id => $arg) {
            $promises[$id] = static::parallelize($pool, $function, array($arg))->then(null, function (\Throwable $e) {
                return $e;
            });
        }
        
        return \React\Promise\all($promises)->then(function (array $result) use ($array) {
            $result = static::convertResult($result);
            
            foreach($array as $key => $_) {
                if(!$result[$key]) {
                    unset($array[$key]);
                }
            }
            
            return $array;
        });
    }
static function filter(\CharlotteDunois\Phoebe\Pool $pool, array $array, ?callable $function = null) {
        if($function === null) {
            $function = function ($value) {
                return ((bool) $value); // @codeCoverageIgnore
            };
        }
        
        $promises = array();
        
        foreach($array as $id => $arg) {
            $promises[$id] = static::parallelize($pool, $function, array($arg))->then(null, function (\Throwable $e) {
                return $e;
            });
        }
        
        return \React\Promise\all($promises)->then(function (array $result) use ($array) {
            $result = static::convertResult($result);
            
            foreach($array as $key => $_) {
                if(!$result[$key]) {
                    unset($array[$key]);
                }
            }
            
            return $array;
        });
    }
static function filter ( \ CharlotteDunois \ Phoebe \ Pool $ pool , array $ array , ? callable $ function = null ) { if ( $ function === null ) { $ function = function ( $ value ) { return ( ( bool ) $ value ) ; // @codeCoverageIgnore } ; } $ promises = array ( ) ; foreach ( $ array as $ id => $ arg ) { $ promises [ $ id ] = static :: parallelize ( $ pool , $ function , array ( $ arg ) ) -> then ( null , function ( \ Throwable $ e ) { return $ e ; } ) ; } return \ React \ Promise \ all ( $ promises ) -> then ( function ( array $ result ) use ( $ array ) { $ result = static :: convertResult ( $ result ) ; foreach ( $ array as $ key => $ _ ) { if ( ! $ result [ $ key ] ) { unset ( $ array [ $ key ] ) ; } } return $ array ; } ) ; }
Parallelizes a given function across a number of available workers, collects the values passing the truth test and reconstructs the array.

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|null                 $function
@return \React\Promise\PromiseInterface
@throws \CharlotteDunois\Phoebe\MultiReasonException  The exception the promise gets rejected with.
Parallelizes a given function across a number of available workers collects the values passing the truth test and reconstructs the array .