Class List Method List File List

# Module: Vertx::WriteStream

Included in:
  HttpClientRequest, HttpServerResponse, NetSocket, SockJSSocket, WebSocket
Defined in:
  src/main/ruby_scripts/core/streams.rb

## Overview

A mixin module which represents a stream of data that can be written to. Any class that mixes in this module can be used by a Pump to pump data from a ReadStream to it.

Author:

- Tim Fox

## Instance Method Summary (collapse)

- - (Object) drain_handler(&hndlr)
  Set a drain handler on the stream.
- - (Object) exception_handler(&hndlr)
  Set an execption handler on the stream.
- - (Object) write_buffer(buff)
  Write some data to the stream.
- - (Boolean) write_queue_full?
  Is the write queue full?.
- - (Object) write_queue_max_size=(size)
  Set the maximum size of the write queue.

## Instance Method Details

### - (`Object`) drain_handler(&hndlr)

Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue has been reduced to maxSize / 2. See Pump for an example of this being used.

Parameters:

- hndlr. (`Block`) —
  The drain handler

    49
    50
    51
    # File 'src/main/ruby_scripts/core/streams.rb', line 49

    def drain_handler(&hndlr)
      @j_del.drainHandler(hndlr)
    end

### - (`Object`) exception_handler(&hndlr)

Set an execption handler on the stream.

Parameters:

- hndlr. (`Block`) —
  The exception handler

    55
    56
    57
    # File 'src/main/ruby_scripts/core/streams.rb', line 55

    def exception_handler(&hndlr)
      @j_del.exceptionHandler(hndlr)
    end

### - (`Object`) write_buffer(buff)

Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the #write_queue_full? method before writing. This is done automatically if using a Pump.

Parameters:

- . (`Buffer`) —
  The buffer to write.

    28
    29
    30
    # File 'src/main/ruby_scripts/core/streams.rb', line 28

    def write_buffer(buff)
      @j_del.writeBuffer(buff._to_java_buffer)
    end

### - (`Boolean`) write_queue_full?

Is the write queue full?

Returns:

- (`Boolean`) —
  true if there are more bytes in the write queue than the max write queue size.

    42
    43
    44
    # File 'src/main/ruby_scripts/core/streams.rb', line 42

    def write_queue_full?
      @j_del.writeQueueFull
    end

### - (`Object`) write_queue_max_size=(size)

Set the maximum size of the write queue. You will still be able to write to the stream even if there is more data than this in the write queue. This is used as an indicator by classes such as Pump to provide flow control.

Parameters:

- size. (`FixNum`) —
  The maximum size, in bytes.

    36
    37
    38
    # File 'src/main/ruby_scripts/core/streams.rb', line 36

    def write_queue_max_size=(size)
      @j_del.setWriteQueueMaxSize(size)
    end