If I take the example from the documentation but I add WithResult:
func main() {
p, _ := workerpool.NewPoolWithResults(4, func(job workerpool.Job[float64], workerID int) (int, error) {
result := math.Sqrt(job.Payload)
fmt.Println("result:", result)
return 0, nil
})
for i := 0; i < 100; i++ {
p.Submit(float64(i))
}
p.StopAndWait()
for result := range p.Results {
fmt.Println(result)
}
}
the code never stops and is stuck at iteration ~3