Files
OllamaScanner/utils/goroutine_pool.go
expvintl 6e5b3875f9 init
2025-02-21 20:28:02 +08:00

28 lines
422 B
Go

package utils
import (
"fmt"
"sync"
"github.com/panjf2000/ants"
)
type PoolInfo struct {
Pool *ants.Pool
MaxWorkers int
TaskWaitGroup sync.WaitGroup
}
func (pool *PoolInfo) NewPool(num int) {
p, err := ants.NewPool(num)
if err != nil {
fmt.Println("Create Pool Error:", err)
return
}
pool.Pool = p
pool.MaxWorkers = num
}
func (pool *PoolInfo) AddTask(fun func()) {
pool.Pool.Submit(fun)
}