class

TermBuf::Input::Reader

Inherits Reference < Object

The fibre that reads the terminal and nothing else.

It does no decoding, which is the point: a read from a real device blocks its thread, so the only thing that should happen on that thread is the read. What comes back goes onto a channel and someone else's fibre makes sense of it.

Constants

BUFFER_SIZE = 4096

One read's worth. Large enough that a paste arrives in few enough pieces to be cheap, small enough to cost nothing when idle.

CAPACITY = 16

Reads waiting to be decoded. Once this fills the reader stops reading, which is the right way round: the kernel's own buffer then applies backpressure to the keyboard rather than memory growing here.

Constructors

new(io : IO, blocking : Bool)

Builds a reader over io, which is not read from until #start.

blocking says whether a read on io blocks the thread it runs on, which is what decides where #start puts the loop. See #start.

Source

Instance methods

inbound

What has been read, in the order it was read.

Source
start

Starts reading.

A blocking read on a real device needs a thread of its own, or it stalls every fibre sharing one. An in-memory stream returns straight away and does not.

Source
started?

Whether the reader is running.

Source

Nested types