-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add PipeReader.Create from ReadOnlySequence<byte> #48369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PipeReader.Create from ReadOnlySequence<byte> #48369
Conversation
Add new factory method to PipeReader to create a PipeReader from a ReadOnlySequence<byte>. Fix dotnet#47990
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
I'm going to go through this again in a couple of days but I believe this is mostly done and ready for review. @davidfowl said you wanted to take a look at it? I've mostly copied tests from the stream pipe reader implementation, and removed tests that weren't applicable (like testing that the stream is disposed, etc.) |
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Outdated
Show resolved
Hide resolved
|
||
private bool TryReadInternal(CancellationTokenSource source, out ReadResult result) | ||
{ | ||
bool isCancellationRequested = source.IsCancellationRequested; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the cancellation logic is needed.
return false; | ||
} | ||
|
||
private void ClearCancellationToken() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same (not needed)
Remove cancellation token source and replace with atomic int operations to keep track of whether or not a cancellation has been requested.
} | ||
|
||
/// <summary> | ||
/// Creates a <see cref="PipeReader"/> wrapping the specified <see cref="ReadOnlySequence{T}"/>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this fine? It points to the docs for ReadOnlySequence<T>
, with no indication of it being only for bytes. Is this just how things are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that how the other docs are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to google this issue (because you can't do ReadOnlySequence<byte>
), and the idea here is that there is no docs page to link to for ReadOnlySequence<byte>
, but the is for ReadOnlySequence<T>
, so that is why I believe. I'm not sure where else I would find docs like this in .NET as I can't recall any off the top of my head at least.
This comment has been minimized.
This comment has been minimized.
This looks good. |
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Outdated
Show resolved
Hide resolved
Use `ReadOnlySequence<byte>.Empty` instead of `_sequence` when `_sequence` is known to be empty. Co-authored-by: Stephen Halter <[email protected]>
Arg, now there's a conflict. Sorry @Alxandr . Can you resolve it? |
Yep. Will do :) |
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Show resolved
Hide resolved
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/SequencePipeReader.cs
Show resolved
Hide resolved
Replace `var` with `bool` and `ReadResult` in 2 places, and make `SequencePipeReader` sealed. Co-authored-by: Stephen Toub <[email protected]>
@Alxandr still need to fix the merge conflict |
I know. I just had to be on a machine with a dev environment set up for that. The previous pushes has just been done through GitHub web UI. |
Per suggestion of @stephentoub
/azp run runtime-staging |
/azp run runtime |
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 1 pipeline(s). |
I'm not sure whether or not these errors are related to code I did or not? I'm not seeing what went wrong in ADO (though, I'm probably just reading it wrong). |
Errors are unrelated. |
Thanks @Alxandr ! |
Add new factory method to PipeReader to create a PipeReader from a ReadOnlySequence.
Fix #47990