task package: replace waitgroup with channel, fix stuck

This commit is contained in:
yusing
2025-01-02 11:12:13 +08:00
parent af14966b09
commit 2fe0b888bd
5 changed files with 152 additions and 102 deletions

26
internal/task/debug.go Normal file
View File

@@ -0,0 +1,26 @@
package task
import "strings"
// debug only.
func (t *Task) listChildren() []string {
var children []string
allTasks.Range(func(child *Task) bool {
if child.parent == t {
children = append(children, strings.TrimPrefix(child.name, t.name+"."))
}
return true
})
return children
}
// debug only.
func (t *Task) listCallbacks() []string {
var callbacks []string
t.mu.Lock()
defer t.mu.Unlock()
for c := range t.callbacks {
callbacks = append(callbacks, c.about)
}
return callbacks
}