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

Notice: ext-swoole is supported until v4.7.1, use ext-openswoole >= v4.7.1. Latest version: pecl install openswoole-4.9.1

Declaration

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

//100ms
Swoole\Process::alarm(100 * 1000);