Swoole Server defer

public void Swoole\Server::defer ( callable $callback )

Delay execution of the callback function at the end of current EventLoop. Alias of function swoole_event_defer().

Parameter

  • $callback the function that defers to execute

Return

void

Example

<?php
function query($server, $db) {
    $server->defer(function() use ($db) {
        $db->close();
    });
}