PHP 8.3.0 RC 6 available for testing

Worker::getStacked

(PECL pthreads >= 2.0.0)

Worker::getStacked获取剩余的栈大小

说明

public Worker::getStacked(): int

返回栈中剩余的任务数量

参数

此函数没有参数。

返回值

返回 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

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top