class Concurrent

Properties

protected Channel $channel

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.

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

Create a new coroutine with concurrency limiting and parent context propagation.

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

Details

at line 22
__construct(int $limit)

No description

Parameters

int $limit

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

at line 45
int getLimit()

Get the concurrency limit.

Return Value

int

at line 53
int getRunningCoroutineCount()

Get the current number of running coroutines.

Return Value

int

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 88
void create(callable $callable)

Create a new coroutine with concurrency limiting.

Parameters

callable $callable

Return Value

void

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

Create a new coroutine with concurrency limiting and parent context propagation.

Parameters

callable $callable
array $keys

Context keys to copy (empty = all keys)

Return Value

void

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

at line 149
protected void acquireSlot()

Acquire one concurrency slot.

Return Value

void

at line 18
bool isFull()

No description

Return Value

bool

at line 18
bool isEmpty()

No description

Return Value

bool