Pool::_construct() 函數可以創建一個新的 Pool of Workers。
用法
public Pool Pool::__construct( integer $size [, string $class [, array $ctor ]] )
Pool::_construct() 函數可以構造一個新的工作池。池懶惰地創建它們的線程,這意味著新線程隻能在需要執行任務時產生。
Pool::_construct() 函數可以返回一個新的池。
示例
<?php
class MyWorker extends Worker {
public function __construct(Something $something) {
$this->something = $something;
}
public function run() {
/** ... **/
}
}
$pool = new Pool(8, \MyWorker::class, [new Something()]);
var_dump($pool);
?>
相關用法
- PHP Pool::collect()用法及代碼示例
- PHP Pool::submitTo()用法及代碼示例
- PHP Pool::submit()用法及代碼示例
- 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::construct() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。