« Swoole\Timer::exists
Swoole\Timer::list »

Swoole\Timer::info

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

Swoole\Timer::info — Get information about a timer.

説明

public static function Swoole\Timer::info(int $timer_id): ?array

Get information about a timer. As of Swoole 4.4.0.

パラメータ

timer_id

The timer ID returned by Swoole\Timer::tick() or Swoole\Timer::after().

戻り値

Returns an array describing the timer, or null if no timer with this ID exists in the current process. The array contains the following keys:

exec_msec

The time of the next execution, in milliseconds, counted from the moment the timer subsystem was started. It is not a duration.

exec_count

The number of times the callback has been executed. Available as of Swoole 4.8.0.

interval

The interval of the timer, in milliseconds.

round

The number of the timer loop round in which the timer was created.

removed

Whether the timer has been removed.

例

例1 Swoole\Timer::info() example

<?php
$timer_id = Swoole\Timer::tick(1000, function () {});
var_dump(Swoole\Timer::info($timer_id));
Swoole\Timer::clear($timer_id);
?>

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

array(5) {
  ["exec_msec"]=>
  int(1000)
  ["exec_count"]=>
  int(0)
  ["interval"]=>
  int(1000)
  ["round"]=>
  int(0)
  ["removed"]=>
  bool(false)
}
関連キーワード:
timer   Swoole   Timer   exec   interval   round   exists   tick   msec   milliseconds   number   list   static   process   contains   keys   execution   counted   moment   subsystem   started   duration   callback   executed   loop
関連する関数・ページ:
swoole-timer.exists   swoole-timer.stats   swoole-timer.clear   swoole-timer.tick   swoole-timer.after   swoole-timer.list