-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented ReadAtLeastAsync (#51979)
- Implemented the PipeReader implementation and override the method on Pipe. - The Pipe implementation has some caveats. Calling ReadAtLeast messes with the pipe back pressure since it's trying to prevent deadlocks. This means that if ReadAsync is called with a big threshold, the writer will write as fast as it can ignoring the PauseThreshold up until the reader is unblocked. In a sense, the call to ReadAtLeast async overrides the pause threshold for that one read. - Added tests
- Loading branch information
Showing
11 changed files
with
330 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/libraries/System.IO.Pipelines/tests/Infrastructure/BasePipeReader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System.IO.Pipelines.Tests | ||
{ | ||
// This is a PipeReader implementation that does not override any of the virtual methods. | ||
// The intent is to test the base implementation without having to rewrite the base functionality | ||
// of the PipeReader. | ||
public class BasePipeReader : PipeReader | ||
{ | ||
private readonly PipeReader _reader; | ||
|
||
public BasePipeReader(PipeReader reader) | ||
{ | ||
_reader = reader; | ||
} | ||
|
||
public override void AdvanceTo(SequencePosition consumed) => _reader.AdvanceTo(consumed); | ||
public override void AdvanceTo(SequencePosition consumed, SequencePosition examined) => _reader.AdvanceTo(consumed, examined); | ||
public override void CancelPendingRead() => _reader.CancelPendingRead(); | ||
public override void Complete(Exception? exception = null) => _reader.Complete(exception); | ||
public override ValueTask<ReadResult> ReadAsync(CancellationToken cancellationToken = default) => _reader.ReadAsync(cancellationToken); | ||
public override bool TryRead(out ReadResult result) => _reader.TryRead(out result); | ||
} | ||
} |
Oops, something went wrong.