LEVIATHAN v962456e · 962456eee1

Standard Library

class IOStream<T>

A stream that can be both read and written, with both ends over one queue.

since 0.1.0-alpha.1linuxwindows

bases
InStream<T>, OutStream<T>

Overview

An IOStream has everything an InStream and an OutStream have: write with <<, read with pull, pullOrNone, subscribe, for or asSeq, and close with close. Values written to it come back out of it in order.

Examples

StreamBuffer<string> buf = StreamBuffer();
IOStream<string> pipe = IOStream(buf);
pipe << "ping" << "pong";
console.writeln(pipe.pull());
console.writeln(pipe.pull());
console.writeln(pipe.hasData());
pipe.close();
pipe << "late";
console.writeln(pipe.hasData());
ping
pong
false
false

Constructors

new

new(StreamBuffer<T> b)

Create a read and write stream over the buffer b.

Parameters

b
The buffer shared by both ends.

Examples

IOStream<int> pipe = IOStream(StreamBuffer());
pipe << 5;
console.writeln(pipe.pull());
5

See also

  • InStream — The reading end of a stream: a queue of values of type T that something else produces.
  • OutStream — The writing end of a stream: you push values of type T in, and a reader takes them out.