package routine import ( "sync" "github.com/langgenius/dify-plugin-daemon/internal/utils/log" "github.com/panjf2000/ants" ) var ( p *ants.Pool l sync.Mutex ) func IsInit() bool { l.Lock() defer l.Unlock() return p != nil } func InitPool(size int) { l.Lock() defer l.Unlock() if p != nil { return } log.Info("init routine pool, size: %d", size) p, _ = ants.NewPool(size, ants.WithNonblocking(false)) } func Submit(f func()) { p.Submit(f) }