Class PipeReader<T>
- Namespace
- MarymoorStudios.Core.Rpc
- Assembly
- MarymoorStudios.Core.Rpc.dll
Capability for reading an ordered sequence of items from a pipe.
public abstract class PipeReader<T> : IPromiseDisposable, IDisposable
Type Parameters
T
- Inheritance
-
PipeReader<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
PipeReader()
protected PipeReader()
Methods
Cancel(Exception?)
Attempts to perform a graceful early termination by the Reader with a diagnostic error for the Writer.
public abstract void Cancel(Exception? error = null)
Parameters
error
ExceptionAn optional diagnostic error. If no error is provided then OperationCanceledException will be sent.
Remarks
The Read() method will eventually return EOS (or error) after Cancel(Exception?) has been called, either because cancellation is successfully propagated to the Writer or because the underlying channel is aborted before cancellation can be propagated.
Cancellation is pr
Dispose()
Releases all received but unread items.
public void Dispose()
Remarks
Implies a call to Cancel(Exception?) if the sequence has not seen EOS or already been cancelled.
Any items that are received by the transport after the Reader has been disposed will be immediately released.
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
DisposeAsync()
Releases all received but unread items.
public Promise DisposeAsync()
Returns
- Promise
A promise that resolves when all in-flight items have been exhausted from the transport.
Remarks
Implies a call to Cancel(Exception?) if the sequence has not seen EOS or already been cancelled.
Any items that are received by the transport after the Reader has been disposed will be immediately released.
DisposeAsyncCore()
protected virtual Promise DisposeAsyncCore()
Returns
Read()
Reads the next available item from the pipe.
public abstract Promise<T> Read()
Returns
- Promise<T>
The next item or an error.
Remarks
Returns the next item in the sequence. If there are no items available immediately, then the return resolves when the next item arrives.
On a successful return ownership for the item returned is transferred to the caller who is responsible for disposing it.
If the end of the sequence (EOS) is reached (i.e. a finite sequence) then reading after the EOS will yield an EndOfSequenceException error.
If the sequence is closed by the Writer with an error, that error will be returned in sequence order after all items successfully written before the error have been delivered.
If the sequence is aborted by the Writer or the underlying pipe transport a read will yield an AbortedException. Some items in the sequence may have been lost in the event of an abort.