2017-12-13 22:58:26 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
|
2017-12-14 17:01:25 +01:00
|
|
|
use function Amp\ParallelFunctions\parallelMap;
|
2017-12-13 22:58:26 +01:00
|
|
|
use function Amp\Promise\wait;
|
|
|
|
|
2017-12-13 23:48:03 +01:00
|
|
|
$start = \microtime(true);
|
2017-12-13 22:58:26 +01:00
|
|
|
|
|
|
|
// sleep() is executed in child processes, the results are sent back to the parent.
|
|
|
|
//
|
|
|
|
// All communication is non-blocking and can be used in an event loop. Amp\Promise\wait() can be used to use the library
|
|
|
|
// in a traditional synchronous environment.
|
2017-12-14 17:01:25 +01:00
|
|
|
wait(parallelMap([1, 2, 3], 'sleep'));
|
2017-12-13 22:58:26 +01:00
|
|
|
|
2018-10-28 16:29:02 +01:00
|
|
|
print 'Took ' . (\microtime(true) - $start) . ' seconds.' . \PHP_EOL;
|