Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions workers/taskpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ func NewTaskPool(size int) *taskPool {
// Do runs the task in a goroutine, ensuring no more tasks are running than the size of the pool.
func (p *taskPool) Do(task func() error) {
p.pool <- struct{}{}
p.wg.Go(func() {
p.wg.Add(1)
go func() {
defer p.wg.Done()
defer func() { <-p.pool }()

err := task()
p.recordError(err)
})
}()
}

func (p *taskPool) recordError(err error) {
Expand Down