Swoole\Event->cycle

Declaration

<?php
Swoole\Event->cycle(callable $callback, bool $before = false)

Parameters

callback

callback function

before

before or after the event loop

Return

success

if success, it returns TRUE, otherwise it returns FALSE.

Description

Registe a callback function which is executed every loop.

Example

<?php
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);
    });
});