• PHP Video Tutorials

PHP - Pool::construct() Function



Pool::_construct() function can create a new Pool of Workers.

Syntax

public Pool Pool::__construct( integer $size [, string $class [, array $ctor ]] )

Pool::_construct() function can construct a new pool of workers. Pools lazily create their threads that mean new threads can only be spawned when they are required to execute tasks.

Pool::_construct() function can return a new pool.

Example

<?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_function_reference.htm
Advertisements