Skip to content

Commit 1eeb529

Browse files
committed
go/common/workerpool: Fix workerpool (tentative)
This could remove the need for previous commit.
1 parent 079e8a4 commit 1eeb529

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

.changelog/6444.trivial.md

Whitespace-only changes.

go/common/workerpool/workerpool.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ func (p *Pool) Stop() {
8181
close(p.stopCh)
8282
})
8383

84-
for range p.jobCh.Out() { //nolint:revive
84+
for item := range p.jobCh.Out() { //nolint:revive
85+
job := item.(*jobDescriptor)
86+
if job.completeCh != nil {
87+
close(job.completeCh)
88+
}
8589
// Clear the channel to close all go routines and prevent memory leaks.
8690
}
8791
}
@@ -92,7 +96,7 @@ func (p *Pool) Quit() <-chan struct{} {
9296
}
9397

9498
// Submit adds a task to the pool's queue and returns a channel that will be closed
95-
// once the task is complete.
99+
// once the task is complete or the pool is stopped.
96100
func (p *Pool) Submit(job func()) <-chan struct{} {
97101
p.lock.Lock()
98102
defer p.lock.Unlock()

0 commit comments

Comments
 (0)