-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add TextWriter.CreateBroadcasting #96732
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsCloses #93623
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Does the behavior or the method name still have a chance to change? /// The resulting instance will delegate each operation to each of the writers in <paramref name="writers"/>.
/// For example, calling <see cref="Write(char)"/> will write the specified char to each writer, one after the
/// other. The writers will be written to in the same order as they are specified in <paramref name="writers"/>.
/// An exception from the operation on one writer will prevent the operation from being performed on subsequent writers. For this behavior, |
src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs
Outdated
Show resolved
Hide resolved
When I think Chain, I think of it as first writing everything to the first writer, and then when the first writer is full, writing everything to the second writer, etc., rather than writing everything to everything.
Why? Does that mean you'd expect broadcasting.Write would use Parallel.For across all of the writers? I don't see why broadcast implies concurrent execution. |
My intuition tells me that a sync method usually doesn't contain any concurrent operation but it's normal if an async method contains some concurrent operations. Then considering the name of Broadcast, I would be a little surprised its |
It's exceedingly rare for methods in the core libraries to introduce any concurrency local to their operation (eg fork multiple tasks and then join with them). The only one I can think of off the top of my head is in Microsoft.Extensions and is opt-in. |
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.
It looks good, but it needs some minor polishing before we merge it. Thank you @stephentoub !
PS. I am using "Request changes" on purpose, as agreed in our Stale PRs discussion. To make others start using it and to treat internal and external PRs equally.
src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.IO.Tests/TextWriter/TextWriterTests.cs
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.IO.Tests/TextWriter/TextWriterTests.cs
Outdated
Show resolved
Hide resolved
@adamsitnik, I addressed your feedback. Please re-review. |
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.
LGTM, thank you @stephentoub !
* Add TextWriter.CreateBroadcasting * Address PR feedback
Closes #93623