Streams#

This page covers adding streams, reading their values, calling back on them and removing them. The messages are described under Streams.

Adding Streams#

streams-members [streams] [MUST]

The client streams each kind of member that returns a value: a procedure, a service property, a method, a static method, a class property, and a member another service adds to a class.

streams-bound-static-method [streams, bound-classes] [MUST]

The client streams a static method called through its class bound to the connection.

streams-null-stream-id [streams] [MUST]

A null result for the call that adds a stream raises the encoding error. The next call succeeds.

streams-procedure-returning-an-event [streams] [MUST]

Streaming a procedure that returns an event raises the stream error.

streams-add-twice [streams] [MUST]

Each add makes a new stream with its own id and lifetime, including an add of a call already streamed or removed.

Streams With No Value#

streams-no-value [streams] [MUST]

A stream of a procedure with no return value runs the call on each update, for its effects. Its value is the client’s null value.

streams-no-value-updates-once [streams, callbacks] [MUST]

A stream with no value updates once, after its first run. Its callbacks are called once, with the client’s null value, and a wait after the first update times out.

streams-no-value-error [streams] [MUST]

An error from a call with no value ends its stream with that error.

streams-no-value-remove [streams] [MUST]

Removing a stream with no value stops its runs.

streams-property-setter [streams, dynamic] [MUST]

A stream can be made of a property setter, with the value to set. It sets the property on each update, and its value is the client’s null value.

Handles#

streams-equality [streams] [MUST]

Copies of a stream handle are equal. Handles from two adds of one call are not.

streams-hash [streams] [MUST]

Copies of a stream handle hash equal, in a language that hashes handles.

Rate#

streams-rate [streams] [MUST]

The rate of a stream is 0, for no limit, until the program sets it. The program sets the rate, and reads it back.

streams-rate-takes-effect [streams] [MUST]

A stream with a rate updates at most that many times a second.

Values#

streams-first-value [streams] [MUST]

A stream starts when it is added. Reading its value blocks until the first value arrives.

streams-value-types [streams] [MUST]

A stream delivers a value of any type, such as a null, an enumeration value, a combination of flags, a structure and a collection holding nulls.

streams-value-changes [streams] [MUST]

A stream delivers each change of its value, such as a change to or from a null, NaN or an infinity, and between 0.0 and -0.0. A NaN once read is not new to a wait, as for any other value.

streams-independent-streams [streams] [MUST]

Several streams update independently.

streams-current-after-call [streams] [MUST]

Once a call returns, each stream value is at least as new as the last update the server wrote before the response to the call.

streams-update-with-a-response [streams] [MUST]

The client delivers a stream update that arrives in the same read as the response to a call.

streams-update-with-add-response [streams] [MUST]

The client delivers a stream update that arrives in the same read as the response to the add, before the stream’s handle exists. This holds for a value, for the latest of two values, for an error that ends the stream, and for the firing of an event a call returns.

streams-update-for-an-unknown-id [streams] [MUST]

The client drops an update for a stream id it holds no stream for, such as an update that arrives before the response to the add.

Errors#

streams-error-ends-the-stream [streams] [MUST]

A result with an error ends the stream. Later reads and waits raise the error a call raises for it, after a remove too.

streams-procedure-exception [streams] [MUST]

A procedure that throws an exception ends the stream with the error a call raises for the exception, of the same type and with the same message, whether it throws for the first value or a later one.

streams-undecodable-value [streams] [MUST]

A value that fails to decode is dropped. Its stream keeps its value, takes the next update, and does not end.

Removing Streams#

streams-remove [streams] [MUST]

Removing a stream through its handle ends it at once, for every copy of the handle. Reading it raises the stream error.

streams-remove-twice [streams] [MUST]

Removing a stream again, through any copy of the handle, does nothing. A stream added since keeps running, though the server can give it the removed stream’s id.

streams-scoped-removal [streams] [SHOULD]

A stream can be scoped to a block of code, using the scoping construct of the language. Leaving the block removes the stream: the server stops evaluating it.

streams-drop-last-handle [streams, callbacks] [MUST]

A stream runs while the program holds a handle to it. Callbacks added through a copy of the handle keep running after the copy is dropped. Dropping the last handle removes the stream: the server stops evaluating it, and its callbacks are not called again. Dropping a handle means letting go of it, such as by a destructor or a garbage collection.

streams-update-after-remove [streams] [MUST]

The client drops an update for a removed stream, whether it arrives before or after the response to the remove.

Connection Ends#

streams-read-after-close [streams] [MUST]

Reading or waiting on a stream after the connection closes raises the connection error, with no cause in a language that chains errors. A stream that had ended with an error raises that error instead. Removing the stream does nothing.

streams-connection-failure-cause [streams] [MUST]

A stream that a connection failure ends raises the connection error. In a language that chains errors, the error carries the error that failed the connection as its cause, such as a lost connection or a message that fails to parse.

streams-close-after-failure [streams, callbacks, concurrency] [MUST]

A connection closed after it fails, before its streams have ended, ends them with the connection error and the reason for the failure.

Waiting#

streams-wait [streams] [MUST]

Waiting on a stream returns on its next update.

streams-wait-timeout [streams] [MUST]

Waiting with a timeout returns false when the timeout elapses, and true on an update. The timeout is a deadline for the whole wait.

streams-wait-timeout-values [streams] [MUST]

A zero timeout returns false at once, when no update is pending. An infinite timeout waits with no deadline, as a wait without a timeout does. A negative or NaN timeout raises the argument error.

streams-two-waiters [streams, concurrency] [MUST]

Two waits on one stream both return on its next update.

streams-wake-waiter [streams, concurrency] [MUST]

A wait on a stream ends when the stream is removed, the connection closes or the connection fails. The wait raises the stream error, or the connection error, with the reason for a failure.

Callbacks#

streams-callback [streams, callbacks] [MUST]

A callback is called with each new value, and none is skipped.

streams-callback-order [streams, callbacks] [MUST]

A callback never receives a value older than the last one it received.

streams-callback-values-only [streams, callbacks] [MUST]

A callback receives values only. The error that ends a stream goes to its end callbacks.

streams-remove-callback [streams, callbacks] [MUST]

A removed callback is not called again.

streams-callback-after-remove [streams, callbacks, races] [MUST]

A callback is not called with a value once the program removes its stream, though the value arrived before the remove.

streams-callback-removed-during-update [streams, callbacks, races] [MUST]

A callback removed while an update passes a value to the stream’s callbacks is not called with the value.

streams-update-callback [streams, callbacks] [SHOULD]

A callback for the whole connection is called once per stream update. A removed callback is not called again.

First Calls#

streams-first-call [streams, callbacks] [MUST]

A callback added to a stream that has a value is called once with that value. This is the callback’s first call. Later values follow it.

streams-first-call-on-add [streams, callbacks] [SHOULD]

The first call of a callback is made before the add returns.

streams-first-call-superseded [streams, callbacks, concurrency, races] [MUST]

A first call is skipped if an update passes the callback a newer value first.

streams-queued-value-before-ending [streams, callbacks, concurrency] [MUST]

A value that arrives while a first call runs is passed to the callback once that call returns. This holds when the server ends the stream meanwhile. The end callbacks are then called after the value.

streams-queued-value-dropped-by-remove [streams, callbacks, concurrency] [MUST]

A value that arrives while a first call runs is not passed to the callback once the program removes the stream.

streams-value-as-first-call-ends [streams, callbacks, concurrency, races] [MUST]

A value that arrives once a first call and the values queued during it have been passed, and before the add returns, is passed to the callback.

Callback Errors#

streams-callback-error [streams, callbacks, concurrency] [MUST]

An error raised by a callback leaves the other callbacks and streams running.

streams-callback-fatal-error [streams, callbacks, concurrency] [MUST]

An error of the kind the language keeps apart from its ordinary exceptions, such as an Error in Java, raised by a callback the client runs in the background, leaves the other callbacks and streams running.

streams-first-call-fatal-error [streams, callbacks] [SHOULD]

A fatal error raised by a first call made before the add returns propagates from the add. The add leaves no callback, so later updates do not call it.

End Callbacks#

streams-end-callback [streams, callbacks] [MUST]

An end callback is called once when the stream ends: by a remove, an error, or a close or failure of the connection. The callback receives the error a read of the stream then raises: the stream error, the server’s error, or the connection error.

streams-late-end-callback [streams, callbacks] [MUST]

An end callback added after the stream ends is called at once, with the error that ended the stream.

streams-remove-end-callback [streams, callbacks] [MUST]

A removed end callback is not called.

streams-remove-during-server-ending [streams, callbacks, races] [MUST]

A stream the server has ended, removed before the client wakes its waiters and calls its end callbacks, keeps the server’s error. The remove does nothing, and the end callbacks are called once, with the server’s error.

streams-end-callback-fatal-error-on-remove [streams, callbacks] [MUST]

A fatal error raised by an end callback that a remove calls on the program’s thread propagates from the remove, once the other end callbacks are called and the server has removed the stream.

streams-end-callback-fatal-error-on-close [streams, callbacks] [MUST]

A fatal error raised by an end callback that a close calls on the program’s thread propagates from the close, once the end callbacks of every stream are called.

streams-late-end-callback-fatal-error [streams, callbacks] [MUST]

A fatal error raised by an end callback that its add calls at once, as the stream has ended, propagates from the add.