Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Coroutine::defer(callable $callback): void
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;
OpenSwoole\Coroutine::defer('task');
echo '2' . PHP_EOL;
});
});