This commit is contained in:
世界 2024-01-01 21:54:00 +08:00
parent b1355d7a4b
commit 9e1749e108
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -68,17 +68,24 @@ func (g *Group) RunContextList(contextList []context.Context) error {
var errorAccess sync.Mutex
var returnError error
taskCount := int8(len(g.tasks))
taskCount := len(g.tasks)
for _, task := range g.tasks {
currentTask := task
go func() {
if g.queue != nil {
<-g.queue
select {
case <-taskCancelContext.Done():
errorAccess.Lock()
taskCount--
currentCount := taskCount
if currentCount == 0 {
taskCancel(errTaskSucceed{})
taskFinish(errTaskSucceed{})
}
errorAccess.Unlock()
return
default:
case <-g.queue:
}
}
err := currentTask.Run(taskCancelContext)