Add dynamic worker pool with bounded queue and concurrency tests

This commit is contained in:
2026-10-20 20:26:43 +08:00
commit aa93168583
5 changed files with 1017 additions and 0 deletions

19
pool_bench_test.go Normal file
View File

@@ -0,0 +1,19 @@
package worker
import "testing"
func BenchmarkQueueRingSteady(b *testing.B) {
p, err := New(0, 6)
if err != nil {
b.Fatal(err)
}
task := func() {}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
p.mu.Lock()
p.enqueueLocked(task)
p.dequeueLocked()
p.mu.Unlock()
}
}