class StreamOutput

A writable output used while executing a streamable body in the worker.

Definitions

def initialize(channel)

Initialize a stream output.

Signature

parameter channel Channel

The worker output channel.

Implementation

def initialize(channel)
	@channel = channel
	@closed = false
end

def write(chunk)

Write an output chunk.

Implementation

def write(chunk)
	raise IOError, "The stream output is closed!" if @closed
	
	@channel.write(:chunk, chunk)
	return chunk.bytesize
end

def flush

Flush pending output.

Implementation

def flush
end

def close_write(error = nil)

Close the stream output for writing.

Implementation

def close_write(error = nil)
	@closed = true
end

def close(error = nil)

Close the stream output for writing.

Implementation

def close(error = nil)
	close_write(error)
end

def closed?

Signature

returns Boolean

Whether the output has been closed.

Implementation

def closed?
	@closed
end

def empty?

Signature

returns Boolean

Whether the output contains pending chunks.

Implementation

def empty?
	true
end