-
Couldn't load subscription status.
- Fork 5.2k
Allow un-examining in PipeReader.AdvanceTo(...) #107360
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -447,7 +447,30 @@ internal void CompleteWriter(Exception? exception) | |
|
|
||
| internal void AdvanceReader(in SequencePosition consumed) | ||
| { | ||
| AdvanceReader(consumed, consumed); | ||
| // If the reader is completed | ||
| if (_readerCompletion.IsCompleted) | ||
| { | ||
| ThrowHelper.ThrowInvalidOperationException_NoReadingAllowed(); | ||
| } | ||
|
|
||
| long examinedIndex = consumed.GetInteger(); | ||
| BufferSegment? examinedSegment = (BufferSegment?)consumed.GetObject(); | ||
| if (examinedSegment != null && | ||
| // Avoid the lock if we're examining the entire segment, don't need to look at the last examined index in that case | ||
| examinedSegment.Length - examinedIndex > 0) | ||
| { | ||
| lock (SyncObj) | ||
|
||
| { | ||
| // If the last examined index is further than the consumed pointer, let's use the last examined index | ||
|
|
||
| // _lastExaminedIndex includes the RunningIndex so we remove that to calculate how many bytes we're examining | ||
| examinedIndex = Math.Max(examinedIndex, _lastExaminedIndex - examinedSegment.RunningIndex); | ||
BrennanConroy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| // TODO: Use new SequenceMarshal.TryGetReadOnlySequenceSegment to get the correct data | ||
| // directly casting only works because the type value in ReadOnlySequenceSegment is 0 | ||
BrennanConroy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| AdvanceReader((BufferSegment?)consumed.GetObject(), consumed.GetInteger(), examinedSegment, (int)examinedIndex); | ||
| } | ||
|
|
||
| internal void AdvanceReader(in SequencePosition consumed, in SequencePosition examined) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.