OpenSwoole\Process::alarm (int $interval_usec, int $type = ITIMER_REAL) : bool

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Process::alarm ( int $interval_usec, int $type = ITIMER_REAL) : bool

Parameters

interval_usec

interval

type

alarm type

Return

success

Description

High precision timer which will trigger signal every fixed interval.

Example

<?php
OpenSwoole\Process::signal(SIGALRM, function () {
    static $i = 0;
    echo "#{$i}\talarm\n";
    $i++;
    if ($i > 20) {
        OpenSwoole\Process::alarm(-1);
    }
});

//100ms
OpenSwoole\Process::alarm(100 * 1000);
Last updated on September 1, 2022