-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
fs: add WriteStream.prototype.flush #28519
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
ea56413 to
030dc39
Compare
bnoordhuis
left a comment
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.
I appreciate that you took this on but this isn't quite what I had in mind. I tried to explain how it should work but don't hesitate to ask if anything is still unclear.
54db609 to
14a8cf7
Compare
e4a7187 to
45c2b20
Compare
|
WIP |
|
I'm trying to refactor the buffer poll to the task poll, which can solve if write chunk or do fsync |
|
@himself65 I’m not sure, but maybe #28520 can provide some inspiration? The code ultimately attempts to solve a very similar problem: Integrate flushing operations (and maybe this function here should also be called |
|
so what is the case of example: ws.cork()
ws.write('string')
ws.flush() // or called ws.fsync()
ws.write('string')
ws.uncork()in the current will call |
|
@himself65 That’s indeed trickier… it might be okay to perform the |
b65f54e to
3df464d
Compare
0610606 to
173061f
Compare
| // There is no shutdown() for files. | ||
| WriteStream.prototype.destroySoon = WriteStream.prototype.end; | ||
|
|
||
| WriteStream.prototype._flush = function(cb) { |
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.
Fwiw, the naming is unfortunate here, but please be aware that the stream _flush() method does something very different than what the idea for fsync() calls is; it’s called just after the last chunk of data has been written, and doesn’t have anything to do with actually flushing data to the underlying resource (it’s not a great name, definitely).
8ae28ff to
2935f72
Compare
|
@himself65 ... still want to do this? Converting the PR to a draft given that it's still a work-in-progress |
fix #28513
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes