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

Make stream_len more atomic #108352

Closed
wants to merge 2 commits into from
Closed

Conversation

est31
Copy link
Member

@est31 est31 commented Feb 22, 2023

This makes stream_len atomic for File in an attempt to resolve the concerns brought up during the last stabilization attempt from which stream_len was ultimately removed.

This gives us atomic stream_len for all of the Seek implementations in std (or makes us use atomic stream_len if the underlying construct has such an atomic stream_len):

  • Empty → already returns Ok(0) since f1cd179
  • Cursor<impl Read> → already uses atomic operation since c518f2d
  • File/&File → now uses atomic operation with this PR
  • Box<impl Seek> → now uses inner stream_len
  • &mut impl Seek → now uses inner stream_len
  • BufReader<impl Seek> → now uses inner stream_len
  • BufWriter<impl Seek> → now uses inner stream_len

The only non-atomic implementation remaining is the one on the trait itself, which is unfortunate, but I'm not sure if the alternatives to that are better or not.

cc @sfackler @LukasKalbertodt

@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2023

r? @m-ou-se

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 22, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@est31 est31 changed the title Make stream_len atomic for File Make stream_len more atomic Feb 22, 2023
This is useful if stream_len is overridden by the Seek implementation
of the inner member.
@the8472
Copy link
Member

the8472 commented Feb 22, 2023

Tracking issue: #59359

This makes stream_len atomic for File in an attempt to resolve the concerns brought up during the last stabilization attempt from which stream_len was ultimately removed.

A comment further downthread suggested moving this method to a new trait so that it's only implemented on types that can return the length atomically.

@est31
Copy link
Member Author

est31 commented Feb 22, 2023

@the8472 mhh yeah good point. Closing.

@est31 est31 closed this Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants