Swoole\Coroutine\WaitGroup->count

Declaration

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

Parameters

Return

Description

Get the pending count of the wait group.

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);
        echo $wg->count();
        $wg->done();
    });

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