mirror of
https://github.com/danog/parallel-functions.git
synced 2024-11-26 20:34:49 +01:00
15 lines
459 B
PHP
15 lines
459 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;
|
|
})));
|