Class EmptyPipeReader
- Namespace
- IceRpc
- Assembly
- IceRpc.dll
Implements a stateless and therefore shareable PipeReader over an empty sequence.
public sealed class EmptyPipeReader : PipeReader
- Inheritance
-
EmptyPipeReader
- Inherited Members
- Extension Methods
Remarks
Because this implementation is stateless, it does not implement CancelPendingRead correctly; in practice this discrepancy should not be noticeable.
Properties
Instance
Gets the shared instance of the empty pipe reader.
public static PipeReader Instance { get; }
Property Value
Methods
AdvanceTo(SequencePosition)
Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed.
public override void AdvanceTo(SequencePosition consumed)
Parameters
consumedSequencePositionMarks the extent of the data that has been successfully processed.
AdvanceTo(SequencePosition, SequencePosition)
Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed, read and examined.
public override void AdvanceTo(SequencePosition consumed, SequencePosition examined)
Parameters
consumedSequencePositionMarks the extent of the data that has been successfully processed.
examinedSequencePositionMarks the extent of the data that has been read and examined.
CancelPendingRead()
Cancels the pending ReadAsync(CancellationToken) operation without causing it to throw and without completing the PipeReader. If there is no pending operation, this cancels the next operation.
public override void CancelPendingRead()
Complete(Exception?)
Signals to the producer that the consumer is done reading.
public override void Complete(Exception? exception)
Parameters
exceptionExceptionOptional Exception indicating a failure that's causing the pipeline to complete.
ReadAsync(CancellationToken)
Asynchronously reads a sequence of bytes from the current PipeReader.
public override ValueTask<ReadResult> ReadAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is default.
Returns
- ValueTask<ReadResult>
A ValueTask<TResult> representing the asynchronous read operation.
Exceptions
- OperationCanceledException
The cancellation token was canceled. This exception is stored into the returned task.
TryRead(out ReadResult)
Attempts to synchronously read data the PipeReader.
public override bool TryRead(out ReadResult result)
Parameters
resultReadResultWhen this method returns true, this value is set to a ReadResult instance that represents the result of the read call; otherwise, this value is set to default.