public function discard(Context $context): Promise
    {
        return $context->task(function (Context $context) {
            $len = 0;
            
            try {
                while (null !== ($chunk = yield $this->read($context, 0xFFFF))) {
                    $len += \strlen($chunk);
                }
            } catch (StreamClosedException $e) {
                // Ignore this case as we are discarding all data anyways.
            } finally {
                $this->close();
            }
            
            return $len;
        });
    }
public function discard(Context $context): Promise
    {
        return $context->task(function (Context $context) {
            $len = 0;
            
            try {
                while (null !== ($chunk = yield $this->read($context, 0xFFFF))) {
                    $len += \strlen($chunk);
                }
            } catch (StreamClosedException $e) {
                // Ignore this case as we are discarding all data anyways.
            } finally {
                $this->close();
            }
            
            return $len;
        });
    }
public function discard ( Context $ context ) : Promise { return $ context -> task ( function ( Context $ context ) { $ len = 0 ; try { while ( null !== ( $ chunk = yield $ this -> read ( $ context , 0xFFFF ) ) ) { $ len += \ strlen ( $ chunk ) ; } } catch ( StreamClosedException $ e ) { // Ignore this case as we are discarding all data anyways. } finally { $ this -> close ( ) ; } return $ len ; } ) ; }
Discard remaining stream contents and close the stream.

@param Context $context Async execution context.
@return int Number of bytes that have been discarded.
Discard remaining stream contents and close the stream .