src/Pipe/ReadablePipe.php
public function poll(float $timeout = 0): \Generator
    {
        while (!$this->queue->isEmpty()) {
            /** @var \Icicle\Awaitable\Delayed $delayed */
            $delayed = $this->queue->bottom();
            yield $delayed; // Wait for previous read to complete.
        }

        if (!$this->isReadable()) {
            throw new UnreadableException('The stream is no longer readable.');
        }

        if ('' !== $this->buffer) {
            throw new FailureException('Stream buffer is not empty. Perform another read before polling.');
        }

        $this->queue->push($delayed = new Delayed($this->onCancelled));
        $this->poll->listen($timeout);

        yield $delayed;

        if ('' !== $this->buffer) {
            throw new FailureException('Data unshifted to stream buffer while polling.');
        }

        return ''; // Resolve with empty string.
    }
public function poll(float $timeout = 0): \Generator
    {
        while (!$this->queue->isEmpty()) {
            /** @var \Icicle\Awaitable\Delayed $delayed */
            $delayed = $this->queue->bottom();
            yield $delayed; // Wait for previous read to complete.
        }

        if (!$this->isReadable()) {
            throw new UnreadableException('The stream is no longer readable.');
        }

        if ('' !== $this->buffer) {
            throw new FailureException('Stream buffer is not empty. Perform another read before polling.');
        }

        $this->queue->push($delayed = new Delayed($this->onCancelled));
        $this->poll->listen($timeout);

        yield $delayed;

        if ('' !== $this->buffer) {
            throw new FailureException('Data unshifted to stream buffer while polling.');
        }

        return ''; // Resolve with empty string.
    }
@coroutine

Returns a coroutine fulfilled when there is data available to read in the internal stream buffer. Note that
this method does not consider data that may be available in the internal buffer. This method can be used to
implement functionality that uses the stream socket resource directly.

@param float|int $timeout Number of seconds until the returned coroutine is rejected with a TimeoutException
if no data is received. Use 0 for no timeout.

@return \Generator

@resolve string Empty string.

@throws \Icicle\Awaitable\Exception\TimeoutException If the operation times out.
@throws \Icicle\Stream\Exception\FailureException If the stream buffer is not empty.
@throws \Icicle\Stream\Exception\UnreadableException If the stream is no longer readable.
@throws \Icicle\Stream\Exception\ClosedException If the stream has been closed.