swoole_event_cycle

定义事件循环周期执行函数。此函数会在每一轮事件循环结束时调用。

bool swoole_event_cycle(callable $callback, bool $before = false);

可以同时存在before=truebefore=false两个回调函数。

需要1.9.24或更高版本

使用实例

Swoole\Timer::tick(2000, function ($id) {
	var_dump($id);
});

Swoole\Event::cycle(function () {
	echo "hello [1]\n";
	Swoole\Event::cycle(function () {
		echo "hello [2]\n";
		Swoole\Event::cycle(null);
	});
});