PHP code example of react-parallel / react-parallel

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


$loop = EventLoopFactory::create();
$factory = new Factory($loop);
$factory->loop(); // Returns the event loop, mainly for convenience
$factory->eventLoopBridge(); // Returns the event loop bridge, used as a central place to translate channels and futures to observables and promises
$factory->streams(); // Returns the stream factory, which provides high level stream abstractions
$factory->call(function (int $time): int {
    return $time;
}, [time()]); // Executes the closure passed into this method in a thread and returns a promises for any results coming out of that closure
$factory->lowLevelPool(); // Returns a low level pool that will scale infinitely (as a long as you have resources enough to scale)
$factory->limitedPool(12); // Returns a limited pool with a maximum number of threads specified by you

use React\EventLoop\Factory as EventLoopFactory;
use ReactParallel\Factory;
use ReactParallel\Metrics;
use WyriHaximus\Metrics\Configuration;
use WyriHaximus\Metrics\InMemory\Registry;

$loop = EventLoopFactory::create();
$registry = new Registry(Configuration::create());
$factory = (new Factory($loop))->withMetrics(Metrics::create($registry));