class WaitGroup

Go-style WaitGroup for waiting on multiple coroutines.

Based on swoole/library implementation.

Properties

protected Channel $chan
protected int $count
protected bool $waiting

Methods

__construct(int $delta = 0)

No description

void
add(int $delta = 1)

Add to the counter (call before starting coroutines).

void
done()

Decrement the counter (call when a coroutine completes).

bool
wait(float $timeout = -1)

Block until the counter reaches zero.

int
count()

Get the current counter value.

Details

at line 24
__construct(int $delta = 0)

No description

Parameters

int $delta

at line 38
void add(int $delta = 1)

Add to the counter (call before starting coroutines).

Parameters

int $delta

Return Value

void

Exceptions

BadMethodCallException
InvalidArgumentException

at line 55
void done()

Decrement the counter (call when a coroutine completes).

Return Value

void

Exceptions

BadMethodCallException

at line 74
bool wait(float $timeout = -1)

Block until the counter reaches zero.

Parameters

float $timeout

Timeout in seconds (-1 for unlimited)

Return Value

bool

True if completed, false if timed out

Exceptions

BadMethodCallException

at line 91
int count()

Get the current counter value.

Return Value

int