Skip to content

Commit

Permalink
Fix panic in Jobpool.Wait()
Browse files Browse the repository at this point in the history
  • Loading branch information
ronenh committed Jan 6, 2025
1 parent 6fd6e74 commit 46b6abf
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions jobpool/jobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ func (jp *JobPool[IN, OUT]) Start() {
// Results are returned in the order that jobs were produced.
func (jp *JobPool[IN, OUT]) Wait() []OUT {
close(jp.inbox)
go func() {
jp.wg.Wait()
close(jp.outbox)
}()
jp.wg.Wait()
close(jp.outbox)

results := make([]OUT, len(jp.inbox))
results := make([]OUT, len(jp.outbox))
for result := range jp.outbox {
results[result.index] = result.result
}
Expand Down

0 comments on commit 46b6abf

Please sign in to comment.