Runtime: Why PipeWriter doesn't have synchronous Flush?

Created on 3 Aug 2019  路  5Comments  路  Source: dotnet/runtime

System.IO.Pipelines

area-System.IO.Pipelines

Most helpful comment

This was probably an oversight

I don't think so :wink:
cc: @davidfowl

All 5 comments

Hello @aliveli186 , thank you for your contribution.

This was probably an oversight when the classes were added in this PR to corefx: https://github.com/dotnet/corefx/pull/27007 . I did not find any comments asking about adding a Flush() method.

Would you mind sharing your use case? Why would you prefer to use Flush instead of FlushAsync?

cc @JeremyKuhne

This was probably an oversight

I don't think so :wink:
cc: @davidfowl

@stephentoub @davidfowl so what would be the reason behind not including Flush in the PR I mentioned above? I can't find an explanation in that PR, and there's no mention of the API approval issue for that PR, where I was hoping this would be explained. If it wasn't an oversight, then it would be great to provide an answer in this thread so we can close the issue.

System.IO.Pipelines is intended for high-throughput and scalable processing of data. In a producer/consumer scenario, a writer that flushes may need to wait for the reader to read before the flush can complete, and with a synchronous flush, that would mean blocking a thread (probably a thread pool thread) waiting for some other thread (probably also a thread pool thread) to do the necessary work. That's a recipe for being non-scalable.

Clear as water, thanks @stephentoub . I'll close the issue.

Was this page helpful?
0 / 5 - 0 ratings