PHP - Manual: Worker::getStacked
2024-11-14
(PECL pthreads >= 2.0.0)
Worker::getStacked — 获取剩余的栈大小
返回栈中剩余的任务数量
此函数没有参数。
返回 worker 中等待执行的任务数量
示例 #1 Worker::getStacked 基本示例
<?php
$worker = new Worker();
for ($i = 0; $i < 5; ++$i) {
$worker->stack(new class extends Threaded {});
}
echo "There are {$worker->getStacked()} stacked tasks\n";
以上例程会输出:
There are 5 stacked tasks