Skip to content
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

PipeWriter.Advance with prefix discard #32891

Open
scalablecory opened this issue Feb 26, 2020 · 1 comment
Open

PipeWriter.Advance with prefix discard #32891

scalablecory opened this issue Feb 26, 2020 · 1 comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO.Pipelines backlog-cleanup-candidate An inactive issue that has been marked for automated closure. no-recent-activity
Milestone

Comments

@scalablecory
Copy link
Contributor

This API would allow PipeWriter to be used efficiently with protocols which use variable-length enveloping. Without this, one must first buffer data elsewhere before writing into a PipeWriter.

The basic idea is to write code that over-allocates a prefix for the envelope:
░░░░|░░░░░░░░

And then writes the data:
░░░░|▓▓▓▓▓░░░

And finally writes the variable-length envelope into the prefix:
░░▓▓|▓▓▓▓▓░░░

And then calls Advance() with the number of unused prefix bytes.

Or:

const int maximumEnvelopeLength = 4;

PipeWriter writer = ...;
Span<byte> span = writer.GetSpan(...);

int dataLength = WriteData(span.Slice(maximumEnvelopeLength));
int actualEnvelopeLength = WriteDataEnvelope(dataLength, span.Slice(0, maximumEnvelopeLength));

writer.Advance(dataLength + actualEnvelopeLength, discard: maximumEnvelopeLength - actualEnvelopeLength);
@scalablecory scalablecory added api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO.Pipelines labels Feb 26, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Feb 26, 2020
@BrennanConroy BrennanConroy added this to the Future milestone Jul 8, 2020
@halter73 halter73 removed the untriaged New issue has not been triaged by the area owner label Jul 8, 2020
Copy link
Contributor

Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

This process is part of our issue cleanup automation.

@dotnet-policy-service dotnet-policy-service bot added backlog-cleanup-candidate An inactive issue that has been marked for automated closure. no-recent-activity labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO.Pipelines backlog-cleanup-candidate An inactive issue that has been marked for automated closure. no-recent-activity
Projects
None yet
Development

No branches or pull requests

4 participants