Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 25.x
Latest version:
pecl install openswoole-25.2.0
<?php Swoole\Coroutine\WaitGroup->done()
Mark one corotuine in the WaitGroup
as finished.
<?php
declare(strict_types=1);
use Swoole\Coroutine\WaitGroup;
Co\run(function() {
$wg = new WaitGroup();
go(function () use ($wg) {
$wg->add();
co::sleep(3);
$wg->done();
});
go(function () use ($wg) {
$wg->add();
co::sleep(7);
$wg->done();
});
$wg->wait(1);
});