« Swoole\Timer::info
Swoole\Timer::set »

Swoole\Timer::list

(No version information available, might only be in Git)

Swoole\Timer::list — Get an iterator over the timers of the current process

説明

public static function Swoole\Timer::list(): Swoole\Timer\Iterator

Returns an iterator over the IDs of the timers created from PHP in the current process. Timers created internally by Swoole are not listed. As of Swoole 4.4.0.

戻り値

Returns a Swoole\Timer\Iterator object, which extends ArrayIterator and yields the timer IDs as int values. The iterator is a snapshot taken when the method is called; it is empty when no timer exists.

例

例1 Swoole\Timer::list() example

<?php
Swoole\Timer::tick(1000, function () {});
Swoole\Timer::after(5000, function () {});

foreach (Swoole\Timer::list() as $timer_id) {
    echo $timer_id, "\n";
    Swoole\Timer::clear($timer_id);
}
?>

上の例の出力は、 たとえば以下のようになります。

1
2
関連キーワード:
Swoole   Timer   iterator   list   timer   over   timers   current   process   Iterator   created   info   information   available   static   Timers   internally   listed   extends   ArrayIterator   yields   values   snapshot   taken   method
関連する関数・ページ:
swoole-timer.clear   swoole-timer.stats   swoole-timer.exists   swoole-timer.set   swoole-timer.clearall   swoole-timer.info