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\Core\Coroutine\WaitGroup->done()
Mark one corotuine in the WaitGroup
as finished.
You have to install OpenSwoole core library with
composer require openswoole/core
to use this feature.
<?php
declare(strict_types=1);
use OpenSwoole\Core\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);
});