protected function free(\Throwable $exception = null)
    {
        $this->readable = false;
        $this->writable = false;

        if (null !== $this->delayed) {
            $this->delayed->resolve('');
        }

        if (0 !== $this->hwm) {
            while (!$this->queue->isEmpty()) {
                /** @var \Icicle\Awaitable\Delayed $delayed */
                $delayed = $this->queue->shift();
                $delayed->reject(
                    $exception = $exception ?: new ClosedException('The stream was unexpectedly closed.')
                );
            }
        }
    }
protected function free(\Throwable $exception = null)
    {
        $this->readable = false;
        $this->writable = false;

        if (null !== $this->delayed) {
            $this->delayed->resolve('');
        }

        if (0 !== $this->hwm) {
            while (!$this->queue->isEmpty()) {
                /** @var \Icicle\Awaitable\Delayed $delayed */
                $delayed = $this->queue->shift();
                $delayed->reject(
                    $exception = $exception ?: new ClosedException('The stream was unexpectedly closed.')
                );
            }
        }
    }
protected function free ( \ Throwable $ exception = null ) { $ this -> readable = false ; $ this -> writable = false ; if ( null !== $ this -> delayed ) { $ this -> delayed -> resolve ( '' ) ; } if ( 0 !== $ this -> hwm ) { while ( ! $ this -> queue -> isEmpty ( ) ) { /** @var \Icicle\Awaitable\Delayed $delayed */ $ delayed = $ this -> queue -> shift ( ) ; $ delayed -> reject ( $ exception = $ exception ? : new ClosedException ( 'The stream was unexpectedly closed.' ) ) ; } } }
Closes the stream and rejects any pending promises.

@param \Throwable|null $exception
Closes the stream and rejects any pending promises .