PHP code example of camspiers / pthreads-pool
1. Go to this page and download the library: Download camspiers/pthreads-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/ */
camspiers / pthreads-pool example snippets
namespace Camspiers\Pthreads;
protected function process()
{
// Do some work, and optionally return some data
return range(1, 1000);
}
}
$pool = new Pool();
for ($i = 0; $i < 1000; $i++) {
$pool->submitWork(new Job());
}
// get jobs as they finish
foreach ($pool->getFinishedJobs() as $job) {
var_dump($job->getData());
}
$pool->shutdown();
$loader = new \Camspiers\Pthreads\Pool();
$pool->setLoader($loader);
// Use the pool