class Channel

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

Keep this in sync with the object-pool channel in hypervel/object-pool.

Properties

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

Methods

__construct(int $size)

Create a pool channel.

pop()

Pop an idle connection without waiting.

bool
push(ConnectionInterface $data)

Push an idle connection and wake one waiter.

int
length()

Get the number of connections in the channel.

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 33
__construct(int $size)

Create a pool channel.

Parameters

int $size

at line 42
ConnectionInterface|false pop()

Pop an idle connection without waiting.

Return Value

ConnectionInterface|false

at line 50
bool push(ConnectionInterface $data)

Push an idle connection and wake one waiter.

Parameters

ConnectionInterface $data

Return Value

bool

at line 65
int length()

Get the number of connections in the channel.

Return Value

int

at line 73
bool wait(float $timeout)

Wait for pool state to change.

Parameters

float $timeout

Return Value

bool

at line 97
void signal()

Wake one waiter after a capacity-relevant state change.

Return Value

void

at line 119
protected void pushSignal()

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

Return Value

void

at line 129
void close()

Close the signal channel and wake every waiter.

Return Value

void