class WaitConcurrent extends Concurrent

Properties

protected Channel $channel from  Concurrent
protected WaitGroup $wg
protected array<int, true> $activeCoroutines

Methods

__construct(int $limit)

No description

bool
__call(string $name, array $arguments)

Proxy isFull() and isEmpty() to the channel.

int
getLimit()

Get the concurrency limit.

int
getRunningCoroutineCount()

Get the current number of running coroutines.

bool
waitForAvailableSlot(float $timeout = -1)

Wait until a concurrency slot becomes available.

void
create(callable $callable)

Create a new coroutine with concurrency limiting and wait tracking.

void
fork(callable $callable, array $keys = [])

Create a new coroutine with parent context propagation and wait tracking.

void
start(callable $callable, array|false $copyContext = false, Closure|null $wrapper = null)

Start a coroutine that owns one concurrency slot.

void
acquireSlot()

Acquire one concurrency slot.

bool
isFull()

No description

bool
isEmpty()

No description

void
startAndTrack(callable $callable, array|false $copyContext = false)

Start a coroutine and track it through deferred cleanup.

bool
wait(float $timeout = -1)

Wait for all coroutines to complete.

void
cancel()

Cancel active coroutine bodies.

Details

at line 23
__construct(int $limit)

No description

Parameters

int $limit

in Concurrent at line 33
bool __call(string $name, array $arguments)

Proxy isFull() and isEmpty() to the channel.

Parameters

string $name
array $arguments

Return Value

bool

Exceptions

InvalidArgumentException

in Concurrent at line 45
int getLimit()

Get the concurrency limit.

Return Value

int

in Concurrent at line 53
int getRunningCoroutineCount()

Get the current number of running coroutines.

Return Value

int

in Concurrent at line 64
bool waitForAvailableSlot(float $timeout = -1)

Wait until a concurrency slot becomes available.

The observed slot is released before this method returns. Another producer may claim it first, in which case create() will wait normally.

Parameters

float $timeout

Return Value

bool

at line 33
void create(callable $callable)

Create a new coroutine with concurrency limiting and wait tracking.

Parameters

callable $callable

Return Value

void

at line 43
void fork(callable $callable, array $keys = [])

Create a new coroutine with parent context propagation and wait tracking.

Parameters

callable $callable
array $keys

Context keys to copy (empty = all keys)

Return Value

void

in Concurrent at line 113
protected void start(callable $callable, array|false $copyContext = false, Closure|null $wrapper = null)

Start a coroutine that owns one concurrency slot.

The optional wrapper runs at native child entry and must invoke the supplied runner exactly once. Outside the runner it must not wait for I/O or other work. Finalize ownership before notifying waiters, which may run immediately.

Parameters

callable $callable
array|false $copyContext
Closure|null $wrapper

Return Value

void

in Concurrent at line 149
protected void acquireSlot()

Acquire one concurrency slot.

Return Value

void

at line 16
bool isFull()

No description

Return Value

bool

at line 16
bool isEmpty()

No description

Return Value

bool

at line 53
protected void startAndTrack(callable $callable, array|false $copyContext = false)

Start a coroutine and track it through deferred cleanup.

Parameters

callable $callable
array|false $copyContext

Return Value

void

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

Wait for all coroutines to complete.

Parameters

float $timeout

Timeout in seconds (-1 for unlimited)

Return Value

bool

True if all completed, false if timed out

at line 108
void cancel()

Cancel active coroutine bodies.

Completed bodies running deferred cleanup are no longer active and are not interrupted. Each call targets the bodies active at that time.

Return Value

void