Skip to content

Conversation

@kuhe
Copy link
Contributor

@kuhe kuhe commented Jul 12, 2024

  • splitStream splits a stream into two streams using pipe(PassThrough) or tee() depending on Stream type.
  • headStream collects the first N bytes of a stream.

Use case: peek the head of a stream's copy while leaving the 2nd copy of that original stream intact

Use case: obtain a parallel stream for checksumming

@kuhe kuhe requested review from a team as code owners July 12, 2024 20:28
@kuhe kuhe requested a review from sugmanue July 12, 2024 20:28
@kuhe kuhe force-pushed the feat/split-stream branch from 1137d83 to 2073c8c Compare July 12, 2024 20:41
@kuhe
Copy link
Contributor Author

kuhe commented Jul 15, 2024

I've tested this for memory leaks. As long as the additional split stream reaches reference count 0 it will be garbage collected without needing to explicitly call its destructor or draining it.

@kuhe kuhe merged commit 7cd258f into smithy-lang:main Jul 15, 2024
@kuhe kuhe deleted the feat/split-stream branch July 15, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants