Open
Description
示例代码
package main
import (
"fmt"
"time"
"github.com/devchat-ai/gopool"
)
func main() {
pool := gopool.NewGoPool(10, gopool.WithErrorCallback(func(err error) {
fmt.Println("Task error:", err)
}), gopool.WithTimeout(6*time.Second))
defer pool.Release()
for i := 0; i < 20; i++ {
pool.AddTask(func() (interface{}, error) {
i := i
fmt.Println(i)
time.Sleep(time.Duration(i) * time.Second)
return nil, nil
})
}
pool.Wait()
}
Metadata
Assignees
Labels
No labels