phasync
PollerInterface / readable

Method

PollerInterface::readable

Parks the current coroutine until poll() finds $stream readable.

Description#

public PollerInterface::readable(
    mixed $stream,
    float $timeout = PHP_FLOAT_MAX
): void

A stream closed while waited for is ready. If the wait is cancelled or times out, the stream is no longer waited for when the exception leaves. One coroutine at a time waits to read a stream: a second one gets a LogicException.

Parameters#

$stream mixed
$timeout float = PHP_FLOAT_MAX

Errors / Exceptions#

ExceptionWhen
LogicExceptionIf another coroutine is waiting to read $stream
IOExceptionIf polling fails for this stream
TimeoutExceptionAfter $timeout seconds