當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP Pool::construct()用法及代碼示例


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