mirror of
https://github.com/danog/parallel-functions.git
synced 2024-12-02 09:37:56 +01:00
15 lines
461 B
PHP
15 lines
461 B
PHP
<?php
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use function Amp\ParallelFunctions\parallelMap;
|
|
use function Amp\Promise\wait;
|
|
|
|
// Parallel function execution is nice, but it's even better being able to use closures instead of having to write a
|
|
// function that has to be autoloadable.
|
|
\var_dump(wait(parallelMap([1, 2, 3], function ($time) {
|
|
\sleep($time); // a blocking function call, might also do blocking I/O here
|
|
|
|
return $time * $time;
|
|
})));
|