Revisit back pressure implementation (dotnet/corefx#35711)
authorDavid Fowler <davidfowl@gmail.com>
Sun, 3 Mar 2019 08:16:33 +0000 (00:16 -0800)
committerGitHub <noreply@github.com>
Sun, 3 Mar 2019 08:16:33 +0000 (00:16 -0800)
commit32bc1950f6f85a9e548c7ef82bff12d8bd3059c8
tree096c9625a64ea9e49f2b1677b877a5bcdf572ff8
parent92e2df347f1ca7b1420f1192871902da3f166aa3
Revisit back pressure implementation (dotnet/corefx#35711)

- Today when using a PipeReader from a Pipe, when the pause threshold is hit and the reader does not consume enough data to unblock the writer (enough to reduce the resume threshold) an exception is thrown. This exception is extremely hard to understand and work around since it's based on a limit set by the owner of the Pipe. It leads to people setting an extremely big limit (bigger than the biggest message) or disabling the limit completely.
- The changes the back pressure mechanic to be based on examined instead of consumed. This pauses the writer if the pause threshold is hit, but lets the reader continue to buffer until a logical payload is reached (whatever matters to the protocol).
- This breaks software that relied on these limits to enforce a maximum buffer size and those pieces of code need to now handle their own maximum buffer size.

Commit migrated from https://github.com/dotnet/corefx/commit/ce278ee840561e90b2c6bb9daaee5ff4b9cce293
src/libraries/System.IO.Pipelines/src/Resources/Strings.resx
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/ThrowHelper.cs
src/libraries/System.IO.Pipelines/tests/BackpressureTests.cs
src/libraries/System.IO.Pipelines/tests/PipeLengthTests.cs