Skip to content

Don't flush files if they weren't written to #364

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

Merged
merged 1 commit into from Oct 28, 2019
Merged

Don't flush files if they weren't written to #364

merged 1 commit into from Oct 28, 2019

Conversation

ghost
Copy link

@ghost ghost commented Oct 17, 2019

Before this PR, files that were opened and then never written to would get flushed on drop, which is a useless operation and especially concerning when small files are read.

Newly opened files now start in flushed state. When constructing async_std::fs::File from a std::fs::File, we still have to start in "dirty" (not flushed) state because we don't know if the handle was previously written to.

Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

I'm kind of wondering here if we should have a small internal enum for the flushed state? We're passing bools in params which doesn't make sense when reading. It's spread over multiple files which makes it harder to jump to the definition also. Mostly just a thought, and not sure if worth it.

@skade
Copy link
Collaborator

skade commented Oct 28, 2019

I agree with @yoshuawuyts there, I think an enum would be preferable. Still, as this is internal, I'd merge and patch.

Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, let's merge this!

@yoshuawuyts yoshuawuyts merged commit e567515 into async-rs:master Oct 28, 2019
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.

2 participants