Swoole\Event::defer

Notice: the documentation is suitable for PHP extension swoole until v4.7.1, we only support PHP extension openswoole from v4.7.1

Declaration

<?php
Swoole\Event::defer(callable $callback)\:\ void

Parameters

callback

Defer a function or any callable to the next loop cycle

Return

void

Description

Defer a function or any callable to the next Loop cycle once the current round of the event loop has completed all its tasks. The callable does not accept any parameters but you may use the anonymous function use syntax to pass variables over. This function is executed before the start of the next event loop round.

Example

<?php
Swoole\Event::defer(function(){
    echo "After EventLoop\n";
});