-
Notifications
You must be signed in to change notification settings - Fork 340
More robust file implementation #157
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems significantly better than what we had before. Much easier to follow, and the removal of futures-preview-channel
is a nice bonus!
Rebased on master to enable tests to pass. |
Signed-off-by: Yoshua Wuyts <[email protected]>
157: More robust file implementation r=stjepang a=stjepang This is a reimplementation of the `File`s state machine. The previous implementation was simple and a bit naive. It was not fundamentally wrong but had surprises in some corner cases. For example, if an async read operation was started but we timed out on it, the file cursor would move even though we didn't complete the operation. The new implementation will move the cursor only when read/write operations complete successfully. There was also a deadlock hazard in the case where multiple tasks were concurrently reading or writing to the same file, in which case some task wakeups would be lost. This PR fixes the problem. A nice consequence of this PR: `futures-channel` is now unused, so we can remove it from the dependency list. Co-authored-by: Stjepan Glavina <[email protected]>
bors r+ |
157: More robust file implementation r=stjepang a=stjepang This is a reimplementation of the `File`s state machine. The previous implementation was simple and a bit naive. It was not fundamentally wrong but had surprises in some corner cases. For example, if an async read operation was started but we timed out on it, the file cursor would move even though we didn't complete the operation. The new implementation will move the cursor only when read/write operations complete successfully. There was also a deadlock hazard in the case where multiple tasks were concurrently reading or writing to the same file, in which case some task wakeups would be lost. This PR fixes the problem. A nice consequence of this PR: `futures-channel` is now unused, so we can remove it from the dependency list. Co-authored-by: Stjepan Glavina <[email protected]>
Build succeeded
|
I was trying to get an understanding of how reading a file asynchronously worked in async-std so I perused the source. I'm very new to async. While carefully walking through all the scenarios with the |
This is a reimplementation of the
File
s state machine.The previous implementation was simple and a bit naive. It was not fundamentally wrong but had surprises in some corner cases. For example, if an async read operation was started but we timed out on it, the file cursor would move even though we didn't complete the operation. The new implementation will move the cursor only when read/write operations complete successfully.
There was also a deadlock hazard in the case where multiple tasks were concurrently reading or writing to the same file, in which case some task wakeups would be lost. This PR fixes the problem.
A nice consequence of this PR:
futures-channel
is now unused, so we can remove it from the dependency list.