goAgilePool is a lightweight goroutine pool for Golang, designed for simplicity and high performance
- Customizable goroutine pool size
- Configurable task queue size
- Task timeout control
- Automatic cleanup of idle workers upon timeout
- Efficient worker reuse through FIFO worker queue management
go get github.com/Yiming1997/go-agile-pool
Pool.Submit()
pool := agilepool.NewPool()
pool.InitConfig().
WithCleanPeriod(500 * time.Millisecond).
WithTaskQueueSize(10000).
WithWorkerNumCapacity(20000)
pool.Init()
for i := 0; i < 20000000; i++ {
go func() {
pool.Submit(agilepool.TaskFunc(func() {
time.Sleep(10 * time.Millisecond)
}))
}()
}
pool.Wait() Pool.SubmitBefore()
pool.SubmitBefore(func() {
time.Sleep(10 * time.Millisecond)
}, 5*time.Second)benchmark
BenchmarkAgilePool-14 1 5881506800 ns/op 230601408 B/op 10871762 allocs/op