Skip to content

Commit d00ca5a

Browse files
committed
Stopped job enqueueing while there are no workers to receive the job
1 parent ac372e9 commit d00ca5a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

dispatcher.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ func (d *Dispatcher) WaitUntilIdle() {
149149
// pulls a job from the job queue and adds it to the worker's job queue - a worker will grab it in the worker logic
150150
func (d *Dispatcher) dispatch() {
151151
for {
152+
153+
// if there are no workers ready to receive the job, let the job queue fill up
154+
if int(d.RunCount()) == len(d.workerPool) {
155+
continue
156+
}
157+
152158
select {
153159
case job := <-d.jobQueue:
154160
go func() {

0 commit comments

Comments
 (0)