mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 11:57:39 +03:00
Fix task
This commit is contained in:
parent
b1355d7a4b
commit
9e1749e108
1 changed files with 10 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue