PHP code example of wyrihaximus / react-child-process-pool
1. Go to this page and download the library: Download wyrihaximus/react-child-process-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/ */
wyrihaximus / react-child-process-pool example snippets
$loop = EventLoopFactory::create();
Dummy::createFromClass(ReturnChild::class, $loop)->then(function (PoolInterface $pool) {
// Now you have a Dummy pool, which does absolutely nothing
});
$loop = EventLoopFactory::create();
$options = [
Options::SIZE => 5,
];
Fixed::createFromClass(ReturnChild::class, $loop, $options)->then(function (PoolInterface $pool) {
// You now have a pull with 5 always running child processes
});
$loop = EventLoopFactory::create();
$options = [
Options::MIN_SIZE => 0,
Options::MAX_SIZE => 5,
Options::TTL => 0,
];
Flexible::createFromClass(ReturnChild::class, $loop, $options)->then(function (PoolInterface $pool) {
// You now have a pool that spawns no child processes on start.
// But when you call rpc a new child process will be started for
// as long as the pool has work in the queue. With a maximum of five.
});
$loop = EventLoopFactory::create();
CpuCoreCountFlexible::createFromClass(ReturnChild::class, $loop)->then(function (PoolInterface $pool) {
// You now have a Fixed pool with a child process assigned to each CPU core.
});
$loop = EventLoopFactory::create();
CpuCoreCountFlexible::createFromClass(ReturnChild::class, $loop)->then(function (PoolInterface $pool) {
// You now have a Fixed pool with a child process assigned to each CPU core,
// which, just like the Flexible pool, will only run when there is something
// in the queue.
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.