Pool::submitTo() 函数可以将任务提交给特定的 worker 执行。
用法
public int Pool::submitTo( int $worker , Threaded $task )
Pool::submitTo() 函数可以向池中指定的worker提交任务。工作人员从 0 开始索引,并且只有在需要池来创建它们时才能存在。
Pool::submitTo() 函数可以返回接受任务的工人的标识符。
示例
<?php
class Task extends Threaded {
public function run() {
var_dump(Thread::getCurrentThreadID());
}
}
$pool = new Pool(2);
$pool->submit(new Task());
for($i = 0; $i < 5; ++$i) {
$pool->submitTo(0, new Task());
}
$pool->submitTo(1, new Task());
$pool->shutdown();
?>
相关用法
- PHP Pool::submit()用法及代码示例
- PHP Pool::construct()用法及代码示例
- PHP Pool::collect()用法及代码示例
- PHP PHPUnit assertIsNotFloat()用法及代码示例
- PHP disk_total_space()用法及代码示例
- PHP ReflectionClass getTraitAliases()用法及代码示例
- PHP hash_hmac()用法及代码示例
- PHP String wordwrap()用法及代码示例
- PHP SimpleXMLElement children()用法及代码示例
- PHP is_file( )用法及代码示例
- PHP ArrayIterator asort()用法及代码示例
- PHP IntlCalendar getTimeZone()用法及代码示例
- PHP SplPriorityQueue isCorrupted()用法及代码示例
- PHP XMLReader::getParserProperty()用法及代码示例
- PHP imagegif()用法及代码示例
- PHP imageresolution()用法及代码示例
- PHP SplFileInfo getPerms()用法及代码示例
注:本文由纯净天空筛选整理自 PHP - Pool::submitTo() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。