Table of Contents

Class Sequence<T>.Writer

Namespace
MarymoorStudios.Core.Rpc
Assembly
MarymoorStudios.Core.Rpc.dll

The writer capability for a Sequence<T>.

public sealed class Sequence<T>.Writer : IPromiseDisposable, IDisposable
Inheritance
Sequence<T>.Writer
Implements
Inherited Members

Methods

Abort()

Promptly aborts the sequence.

public void Abort()

Remarks

Write initiated abort is best-effort transmitted across the transport to the reader. If the transport has itself been aborted then the abort signal is discarded (but the reader will see an abort from the transport). Any items in flight that cannot be transmitted before the transport has been torn down are immediately released.

Close(Exception?)

Terminates the sequence.

public Promise Close(Exception? error = null)

Parameters

error Exception

An optional error to terminate the sequence with.

Returns

Promise

A promise that resolves when the reader has seen the entire sequence.

Remarks

If the sequence is terminated without an error (a successful termination) the reader will see an End of Sequence (EOS). If an error is provided, the reader will eventually see that error as the result of a call to Read().

Dispose()

Promptly terminates the sequence.

public void Dispose()

Remarks

If the sequence is already terminated or a graceful Close(Exception?) can be promptly transmitted on the transport, it is done. Otherwise, an Abort() occurs. If any untransmitted items cannot be promptly transmitted they are released without being transmitted and the termination becomes an Abort().

DisposeAsync()

Asynchronously terminates the sequence.

public Promise DisposeAsync()

Returns

Promise

Remarks

If the sequence is not already terminated, a graceful Close(Exception?) is performed. The result then resolves after a graceful termination acknowledgement is received from the reader (indicating that all items have been received including the graceful termination signal).

If the transport is torn down before all pending items can be transmitted, or before a graceful termination acknowledgement has been received from the reader, then any untransmitted items are released without being transmitted and the termination becomes an Abort().

~Writer()

protected ~Writer()

Flush()

Returns a promise that resolves when flow control would allow additional writes without buffering.

public Promise Flush()

Returns

Promise

Remarks

If there is no flow control pressure the return value will be promptly resolved.

Write(T)

Writes an item to the sequence.

public void Write(T item)

Parameters

item T

The item to be written.

Remarks

On a successful return, ownership of the provided item is transferred to the sequence. Items successfully written to the sequence but never delivered to a reader (e.g. because the sequence is disposed or the transport is terminated) will be disposed by the sequence itself.

The error EndOfSequenceException occurs when the Writer comes to know that the sequence has been disposed before the EOS has been written. This error will be thrown repeatedly on all subsequent writes after this point. The Writer should gracefully terminate production.

If the sequence is cancelled by the reader (optionally with an error), OperationCanceledException) (or that error) will be returned by the next call to Write(T) or Flush() after the Writer comes to know of the cancellation. Cancellation is propagated asynchronously backward through the transport and may be subject to propagation delay. Cancellation delivery cannot be guaranteed as it may be lost if the underlying channel is aborted before it can be delivered.

If the sequence is aborted by the reader or the underlying transport, a call to Write(T) or Flush() will yield an AbortedException. Some items in the sequence may have been lost in the event of an abort.