Skip to content

wait with context to avoid blocking#9

Open
jwmach1 wants to merge 1 commit intoremeh:masterfrom
jwmach1:wait-with-context
Open

wait with context to avoid blocking#9
jwmach1 wants to merge 1 commit intoremeh:masterfrom
jwmach1:wait-with-context

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