-
-
Notifications
You must be signed in to change notification settings - Fork 72
Closed
Description
Hello!
Please consider to review following example:
package main
import (
"context"
"runtime"
"time"
"github.com/alitto/pond/v2"
)
func main() {
const (
maxWorkers = 2
queueSize = 10
numJobs = 100
)
wp := pond.NewPool(
maxWorkers,
pond.WithNonBlocking(true),
pond.WithQueueSize(queueSize),
pond.WithContext(context.Background()),
)
for i := 0; i < numJobs; i++ {
wp.Submit(func() {
time.Sleep(100 * time.Millisecond)
})
}
println(runtime.GOMAXPROCS(0)) // 8
go func() {
time.Sleep(time.Second * 10)
println(wp.SubmittedTasks()) // 12
println(wp.CompletedTasks()) // 12
println(wp.SuccessfulTasks()) // 12
println(wp.FailedTasks()) // 0
}()
time.Sleep(time.Second * 15)
}
Based on the code, I expect that SuccessfulTasks() + FailedTasks()
should be equal SubmittedTasks()
.
However, when the pool is full and operates in non-blocking mode, it silently drops jobs without reflecting this in any statistics.
Am I correct in understanding how these counters are supposed to work? It appears there might be an
inconsistency here.
Metadata
Metadata
Assignees
Labels
No labels