PHP code example of wispedia / kppool
1. Go to this page and download the library: Download wispedia/kppool 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/ */
wispedia / kppool example snippets
use Kppool\Forker\PcntlProcessPool;
use Kppool\Channel\ApcuChannel;
function echo_hello($a) {
var_dump($a);
}
// 第二个参数为初始化进程的数量
$process_pool = new PcntlProcessPool(ApcuChannel::class, 4);
for ($i = 1; $i <= 1000; $i++) {
$process_pool->register("echo_hello", "hello");
}
// run方法会等待所有register的任务完成之后才返回
$process_pool->run();