本文整理汇总了PHP中Pool::start方法的典型用法代码示例。如果您正苦于以下问题:PHP Pool::start方法的具体用法?PHP Pool::start怎么用?PHP Pool::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pool
的用法示例。
在下文中一共展示了Pool::start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pool
/**
* Returns the global worker pool for the current context.
*
* @param PoolInterface|null $pool A worker pool instance.
*
* @return PoolInterface The global worker pool instance.
*/
function pool(PoolInterface $pool = null)
{
static $instance;
if (null !== $pool) {
$instance = $pool;
} elseif (null === $instance) {
$instance = new Pool();
}
if (!$instance->isRunning()) {
$instance->start();
}
return $instance;
}
示例2: startPool
public function startPool(Configuration $config)
{
$config->initialize();
$pool = new Pool($config);
$pool->start();
$pool->join();
}
示例3: run
}
/**
* StagingData to hold data from StageOne
*/
class StagingData extends Stackable
{
public function run()
{
}
}
/* stage and data reference arrays */
$one = [];
$two = [];
$data = [];
$pool = new Pool(8);
$pool->start();
/* construct stage one */
while (count($one) < 10) {
$staging = new StagingData();
/* maintain reference counts by storing return value in normal array in local scope */
$one[] = $pool->submit(new StageOne($staging));
/* maintain reference counts */
$data[] = $staging;
}
/* construct stage two */
while (count($one)) {
/* find completed StageOne objects */
foreach ($one as $id => $job) {
/* if done is set, the data from this StageOne can be used */
if ($job->done) {
/* use each element of data to create new tasks for StageTwo */