<?php
Swoole\Coroutine::defer(callable $callback)
Closure function to be deferred.
Execute the deferred function to be executed at the time when the current coroutine is exiting.
<?php
function task() {
echo '3' . PHP_EOL;
}
Co\run(function () {
go(function () {
echo '1' . PHP_EOL;
Swoole\Coroutine::defer('task');
echo '2' . PHP_EOL;
});
});