PHP code example of react-parallel / infinite-pool
1. Go to this page and download the library: Download react-parallel/infinite-pool library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
react-parallel / infinite-pool example snippets
use React\EventLoop\Factory;
use ReactParallel\EventLoop\EventLoopBridge;
use ReactParallel\Pool\Infinite\Infinite;
$loop = Factory::create();
$infinite = new Infinite($loop, new EventLoopBridge($loop), 1);
$infinite->run(function () {
sleep(1);
return 'Hoi!';
})->then(function (string $message) use ($infinite) {
echo $message, PHP_EOL;
$infinite->close();
});
$loop->run();
use React\EventLoop\Factory;
use ReactParallel\EventLoop\EventLoopBridge;
use ReactParallel\EventLoop\Metrics as EventLoopMetrics;
use ReactParallel\Pool\Infinite\Infinite;
use ReactParallel\Pool\Infinite\Metrics;
use WyriHaximus\Metrics\Configuration;
use WyriHaximus\Metrics\InMemory\Registry;
$loop = Factory::create();
$registry = new Registry(Configuration::create());
$eventLoopBridge = (new EventLoopBridge($loop))->withMetrics(EventLoopMetrics::create($registry));
$finite = (new Infinite($loop, $eventLoopBridge, 1.3))->withMetrics(Metrics::create($registry));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.