class PoolChannel

Store idle objects independently of execution mode and signal coroutine waiters.

Properties

protected T> $queue
protected Channel<bool> $signal
protected int $waiters
protected bool $closed

Methods

__construct(int $size)

Create a pool channel.

false|object
pop()

Retrieve an idle object without waiting.

bool
push(object $data)

Push an idle object and wake one waiter.

int
length()

Get the current number of objects in the channel.

int
waiters()

Get the number of coroutines waiting for pool state to change.

bool
wait(float $timeout)

Wait for pool state to change.

void
signal()

Wake one waiter after a capacity-relevant state change.

void
pushSignal()

Push a coalesced wake signal without blocking on a full channel.

void
close()

Close the signal channel and wake every waiter.

Details

at line 32
__construct(int $size)

Create a pool channel.

Parameters

int $size

at line 43
false|object pop()

Retrieve an idle object without waiting.

Return Value

false|object

at line 53
bool push(object $data)

Push an idle object and wake one waiter.

Parameters

object $data

Return Value

bool

at line 68
int length()

Get the current number of objects in the channel.

Return Value

int

at line 76
int waiters()

Get the number of coroutines waiting for pool state to change.

Return Value

int

at line 84
bool wait(float $timeout)

Wait for pool state to change.

Parameters

float $timeout

Return Value

bool

at line 112
void signal()

Wake one waiter after a capacity-relevant state change.

Return Value

void

at line 134
protected void pushSignal()

Push a coalesced wake signal without blocking on a full channel.

Return Value

void

at line 144
void close()

Close the signal channel and wake every waiter.

Return Value

void