Skip to content

Commit

Permalink
rename quietWait to something that makes more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
mumbleskates committed Oct 9, 2024
1 parent f48896c commit f6332c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ func (pg *pipeGroup[T, R]) doWait() {
}()
// Runs first: Wait for inputs. Wait "quietly", not canceling the
// context yet so if there is an error later we can still see it
pg.g.quietWait()
pg.g.waitWithoutCanceling()
}()
// Runs third: Wait for outputs to be done
pg.pipeWorkers.quietWait()
pg.pipeWorkers.waitWithoutCanceling()
}

var _ CollectingExecutor[int] = collectingGroup[int]{}
Expand Down
14 changes: 7 additions & 7 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type Executor interface {
getContext() (context.Context, context.CancelCauseFunc)
// Waits without canceling the context with errGroupDone. The caller of this
// function promises that they will be responsible for canceling the context
quietWait()
waitWithoutCanceling()
}

// Creates a basic executor which runs all the functions given in one goroutine
Expand Down Expand Up @@ -159,11 +159,11 @@ func (n *runner) Go(op func(context.Context)) {
}

func (n *runner) Wait() {
n.quietWait()
n.waitWithoutCanceling()
n.cancel(errGroupDone)
}

func (n *runner) quietWait() {
func (n *runner) waitWithoutCanceling() {
n.awaited.Store(true)
runtime.SetFinalizer(n, nil)
}
Expand Down Expand Up @@ -243,10 +243,10 @@ func (g *group) Go(op func(context.Context)) {

func (g *group) Wait() {
defer g.cancel(errGroupDone)
g.quietWait()
g.waitWithoutCanceling()
}

func (g *group) quietWait() {
func (g *group) waitWithoutCanceling() {
g.awaited.Store(true)
runtime.SetFinalizer(g, nil)
g.wg.Wait()
Expand Down Expand Up @@ -327,12 +327,12 @@ func (lg *limitedGroup) Wait() {
lg.g.Wait()
}

func (lg *limitedGroup) quietWait() {
func (lg *limitedGroup) waitWithoutCanceling() {
if !lg.awaited.Swap(true) {
close(lg.ops)
runtime.SetFinalizer(lg, nil) // Don't try to close this chan again :)
}
lg.g.quietWait()
lg.g.waitWithoutCanceling()
}

func (lg *limitedGroup) getContext() (context.Context, context.CancelCauseFunc) {
Expand Down

0 comments on commit f6332c8

Please sign in to comment.