本文整理汇总了PHP中Pool::submitTo方法的典型用法代码示例。如果您正苦于以下问题:PHP Pool::submitTo方法的具体用法?PHP Pool::submitTo怎么用?PHP Pool::submitTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pool
的用法示例。
在下文中一共展示了Pool::submitTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitTaskToWorker
public function submitTaskToWorker(AsyncTask $task, $worker)
{
if ($task->isGarbage()) {
return;
}
$worker = (int) $worker;
if ($worker < 0 or $worker >= $this->size) {
throw new \InvalidArgumentException("Invalid worker {$worker}");
}
$this->tasks[$task->getTaskId()] = $task;
$this->pool->submitTo((int) $worker, $task);
}
示例2: testPoolGc
public function testPoolGc()
{
$pool = new Pool(1, PoolTestWorker::class, [new stdClass(), new Threaded()]);
$work = new PoolTestWork();
$pool->submit($work);
while (@$i++ < 2) {
$pool->submit(new PoolTestWork());
# nothing to assert, no exceptions please
}
$pool->submitTo(0, new PoolTestWork());
# nothing to assert, no exceptions please
/* synchronize with pool */
$sync = new PoolTestSync();
$pool->submit($sync);
$sync->synchronized(function ($sync) {
if (!$sync->finished) {
$sync->wait();
}
}, $sync);
$pool->collect(function ($task) {
$this->assertTrue($task->isGarbage());
return true;
});
$pool->shutdown();
}