Open janekolszak opened 1 year ago
Here's the workaround I'm using until workerpool
supports customizable queue size:
var stop bool
for !stop {
if pool.WaitingQueueSize() > DESIRED_QUEUE_SIZE {
time.Sleep(CUSTOM_DURATION) // exponential backoff would probably be better
continue
}
pool.Submit(func() {
// ...
})
}
Hi, I'm in a need of blocking
Submit
until the queue of tasks is small enough. I imagine something likeSubmitBlock( ctx context.Context, minQueueDepth uint, f func())
that waits for the queue to be small enough, inserts the func and immediately returns.Would you like to add something like that or accept a PR?