Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
Latest version:
pecl install openswoole-22.1.2
<?php Swoole\Process::alarm ( int $interval_usec, int $type = ITIMER_REAL) : bool
interval
alarm type
High precision timer which will trigger signal every fixed interval.
<?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);