phpday 2027 - Call for Papers

Worker::getStacked

(PECL pthreads >= 2.0.0)

Worker::getStacked — Obtient la taille de pile restante

Description

public function Worker::getStacked(): int

Retourne le nombre de tâches laissées sur la pile

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne le nombre de tâches actuellement en attente d'être exécutées par le worker

Exemples

Exemple #1 Un exemple de base de Worker::getStacked

<?php
$worker = new Worker();

for ($i = 0; $i < 5; ++$i) {
    $worker->stack(new class extends Threaded {});
}

echo "Il y a {$worker->getStacked()} tâches empilées\n";

L'exemple ci-dessus va afficher :

Il y a 5 tâches empilées

User Contributed Notes

There are no user contributed notes for this page.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top