mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-05 21:07:41 +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 errorAccess sync.Mutex
|
||||||
var returnError error
|
var returnError error
|
||||||
taskCount := int8(len(g.tasks))
|
taskCount := len(g.tasks)
|
||||||
|
|
||||||
for _, task := range g.tasks {
|
for _, task := range g.tasks {
|
||||||
currentTask := task
|
currentTask := task
|
||||||
go func() {
|
go func() {
|
||||||
if g.queue != nil {
|
if g.queue != nil {
|
||||||
<-g.queue
|
|
||||||
select {
|
select {
|
||||||
case <-taskCancelContext.Done():
|
case <-taskCancelContext.Done():
|
||||||
|
errorAccess.Lock()
|
||||||
|
taskCount--
|
||||||
|
currentCount := taskCount
|
||||||
|
if currentCount == 0 {
|
||||||
|
taskCancel(errTaskSucceed{})
|
||||||
|
taskFinish(errTaskSucceed{})
|
||||||
|
}
|
||||||
|
errorAccess.Unlock()
|
||||||
return
|
return
|
||||||
default:
|
case <-g.queue:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err := currentTask.Run(taskCancelContext)
|
err := currentTask.Run(taskCancelContext)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue