PHP 8.6.0 Beta 1 is available for testing

Swoole\Event::cycle

(No version information available, might only be in Git)

Swoole\Event::cycleDefine a function to execute at the end of each event loop iteration

Описание

public static function Swoole\Event::cycle(callable $callback, bool $before = false): bool

Defines a callback function to execute at the end (or beginning, if before is true) of each event loop iteration.

Список параметров

callback
The function to execute. Set to null to clear a previously set cycle function.
before
If true, the callback executes before the event loop; if false, after.

Возвращаемые значения

Функция возвращает true, если выполнилась успешно, или false, если возникла ошибка.

Примеры

Пример #1 Basic usage

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

Swoole\Event::wait();

Добавить

Примечания пользователей

Пользователи ещё не добавляли примечания для страницы
To Top