Skip to content
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

wait with context to avoid blocking #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jwmach1
Copy link

@jwmach1 jwmach1 commented Apr 2, 2021

This is the companion to the AddWithContext(context.Context) method to give Wait the same awareness of cancellation by a context.

Comment on lines +90 to +94
go func() {
defer close(done)
s.Wait()
done <- struct{}{}
}()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will leak goroutine each time WaitWithContext is called w/ an expired context until wg finishes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could document it as such? Given a context that has been cancelled, via os.Interrupt for example, I thought it better to orphan the goroutine and have the application exit when graceful immediate shutdown of all the goroutines in the sizedWaitGroup is not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants