Swoole\Coroutine\WaitGroup->__construct

4.x is outdated, please check the latest version 22.x


Latest version: pecl install openswoole-22.1.2

Declaration

<?php Swoole\Coroutine\WaitGroup->__construct()

Parameters

Return

Description

Create a new WaitGroup.

Example

<?php
declare(strict_types=1);

use Swoole\Coroutine\WaitGroup;

Co\run(function() {
    $wg = new WaitGroup();

    go(function () use ($wg) {
        $wg->add();
        co::usleep(300000);
        $wg->done();
    });

    go(function () use ($wg) {
        $wg->add();
        co::usleep(700000);
        $wg->done();
    });

    $wg->wait(1);
});
Last updated on August 31, 2022