Pump

Pumps data from a @see \io\vertx\jphp\core\streams\ReadStream to a @see \io\vertx\jphp\core\streams\WriteStream and performs flow control where necessary to prevent the write stream buffer from getting overfull.

Instances of this class read items from a @see \io\vertx\jphp\core\streams\ReadStream and write them to a @see \io\vertx\jphp\core\streams\WriteStream. If data can be read faster than it can be written this could result in the write queue of the @see \io\vertx\jphp\core\streams\WriteStream growing without bound, eventually causing it to exhaust all available RAM.

To prevent this, after each write, instances of this class check whether the write queue of the @see \io\vertx\jphp\core\streams\WriteStream is full, and if so, the @see \io\vertx\jphp\core\streams\ReadStream is paused, and a drainHandler is set on the

see

When the @see \io\vertx\jphp\core\streams\WriteStream has processed half of its backlog, the drainHandler will be called, which results in the pump resuming the @see \io\vertx\jphp\core\streams\ReadStream.

This class can be used to pump from any @see \io\vertx\jphp\core\streams\ReadStream to any @see \io\vertx\jphp\core\streams\WriteStream, e.g. from an @see \io\vertx\jphp\core\http\HttpServerRequest to an @see \io\vertx\jphp\core\file\AsyncFile, or from @see \io\vertx\jphp\core\net\NetSocket to a @see \io\vertx\jphp\core\http\WebSocket.

Please see the documentation for more information.

package

Default

Methods

__construct

__construct() 

Return the total number of items pumped by this pump.

numberPumped() : integer

Response

integer

Create a new <code>Pump</code> with the given <code>ReadStream</code> and <code>WriteStream</code>

pump( $arg0,  $arg1,  $arg2 = null) : \io\vertx\jphp\core\streams\Pump
static

param $rs [ReadStream] the read stream param $ws [WriteStream] the write stream pump($rs, $ws)

Create a new Pump with the given ReadStream and WriteStream and writeQueueMaxSize

param $rs [ReadStream] the read stream param $ws [WriteStream] the write stream param $writeQueueMaxSize [integer] the max size of the write queue pump($rs, $ws, $writeQueueMaxSize)

Arguments

$arg0

ReadStream

$arg1

WriteStream

$arg2

integer

Response

\io\vertx\jphp\core\streams\Pump

the pump

Set the write queue max size to <code>maxSize</code>

setWriteQueueMaxSize( $arg0) : $this

Arguments

$arg0

integer

Response

$this

a reference to this, so the API can be used fluently

Start the Pump. The Pump can be started and stopped multiple times.

start() : $this

Response

$this

a reference to this, so the API can be used fluently

Stop the Pump. The Pump can be started and stopped multiple times.

stop() : $this

Response

$this

a reference to this, so the API can be used fluently