优化系统goroutine使用,减少goroutine数量,增加goman查看goroutine数量指令

This commit is contained in:
刘祥超
2021-12-08 15:17:45 +08:00
parent 24fbd740b5
commit 1279f0d394
48 changed files with 469 additions and 146 deletions

View File

@@ -1,15 +1,18 @@
package utils
import "time"
import (
"github.com/TeaOSLab/EdgeNode/internal/goman"
"time"
)
// 定时运行某个函数
// Every 定时运行某个函数
func Every(duration time.Duration, f func(ticker *Ticker)) *Ticker {
ticker := NewTicker(duration)
go func() {
goman.New(func() {
for ticker.Next() {
f(ticker)
}
}()
})
return ticker
}