Pool::__construct
(PECL pthreads >= 2.0.0)
Pool::__construct — Crée un nouveau Pool de Workers
Description
Construit un nouveau Pool de Workers
Liste de paramètres
-
size -
Le nombre maximal de Workers que ce Pool peut créer
-
class -
La classe pour les nouveaux Workers
-
ctor -
Un tableau d'arguments à passer aux nouveaux Workers
Valeurs de retour
Le nouveau Pool
Exemples
Exemple #1 Création d'un Pool
<?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);
?>
L'exemple ci-dessus va afficher :
object(Pool)#1 (6) {
["size":protected]=>
int(8)
["class":protected]=>
string(8) "MyWorker"
["workers":protected]=>
NULL
["work":protected]=>
NULL
["ctor":protected]=>
array(1) {
[0]=>
object(Something)#2 (0) {
}
}
["last":protected]=>
int(0)
}