PHP code example of react-parallel / limited-pool

1. Go to this page and download the library: Download react-parallel/limited-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 / limited-pool example snippets


use React\EventLoop\Loop;
use ReactParallel\EventLoop\EventLoopBridge;
use ReactParallel\Pool\Infinite\Infinite;
use ReactParallel\Pool\Limited\Limited;
use function React\Async\async;

$limited = new Limited(
    new Infinite(new EventLoopBridge(), 1), // Another pool, preferably an inifinite pool
    100 // The amount of threads to start and keep running
);
$time = time();

Loop::futureTick(async(static function () use ($limited, $time) {
    echo 'Unix timestamp: ', $limited->run(function (int $time): int {
        return $time;
    }, [$time]), $time, PHP_EOL;
}));