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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。