-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: sync: add WaitGroup.Notify to use with select #71231
Comments
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Notify
method to sync.WaitGroup
I think this is a strictly worse version of what x/sync/errgroup does. #40916 (comment) is exactly my sentiment:
|
This is a very basic package, don't let |
Hi, so do you want to implement the new functionality? |
@zephyrtronium - I wouldn't compare them one to one. I agree that In my view, this makes compatibility with the I'd even argue that @zigo101 — There is no |
I mean |
Background
Integrating
WaitGroup
withselect
statements, especially in context-aware operations where cancellation might be necessary, requires creating an additional channel for signaling.Proposal
I propose extending
sync.WaitGroup
with a new method:This method would return a channel that is closed when
WaitGroup.Wait
returns.Example
Instead of:
You could do:
Conclusion
This boilerplate it replaces is small, but I believe it does a lot to bring
WaitGroup
closer to the built-in concurrency tools offered by the language.CC #71076.
The text was updated successfully, but these errors were encountered: