Swoole\Coroutine\WaitGroup->done

Declaration

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

Parameters

Return

Description

Mark one corotuine in the WaitGroup as finished.

Example

<?php
declare(strict_types=1);

use Swoole\Coroutine\WaitGroup;

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

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

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

    $wg->wait(1);
});