@@ -108,7 +108,7 @@ func (d *Dispatcher) WithJobErrFn(jobErrFn JobErrorFunction) *Dispatcher {
108108// and it will halt the current thread until the queue becomes available
109109func (d * Dispatcher ) EnqueueJobAllowWait (job Job ) {
110110 if blocked := d .BlockWhileQueueFull (); blocked {
111- _ , _ = d .dispatchLogFn ("blocked during enqueue because queue full" )
111+ _ , _ = d .dispatchLogFn ("blocked during enqueue due to full queue and fully-occupied workers " )
112112 }
113113 d .jobQueue <- job
114114}
@@ -137,10 +137,16 @@ func (d *Dispatcher) BlockWhileQueueFull() bool {
137137
138138 go func () {
139139 for d .IsJobQueueFull () {
140- _ , _ = d .waitLogFn ("blocking due to full work queue" )
140+ if ! didBlock {
141+ _ , _ = d .waitLogFn ("blocking due to full work queue" )
142+ }
141143 didBlock = true
142144 time .Sleep (time .Millisecond * 100 )
143145 }
146+
147+ if didBlock {
148+ _ , _ = d .waitLogFn ("stopped blocking work queue as it is no longer full" )
149+ }
144150 complete <- true
145151 }()
146152
@@ -203,15 +209,23 @@ func (d *Dispatcher) IsAnyWorkerIdle() bool {
203209
204210// 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
205211func (d * Dispatcher ) dispatch () {
212+ runCountAtLastLog := - 1
206213 for {
207214
208215 // if there are no workers ready to receive the job, let the job queue potentially fill up
209216 if ! d .IsAnyWorkerIdle () {
217+ if runCountAtLastLog != cap (d .workerPool ) {
218+ _ , _ = d .dispatchLogFn ("during round-robin dispatching: %d / %d jobs running" , cap (d .workerPool ), cap (d .workerPool ))
219+ runCountAtLastLog = cap (d .workerPool )
220+ }
210221 time .Sleep (50 * time .Millisecond )
211222 continue
212223 }
213224
214- _ , _ = d .dispatchLogFn ("during round-robin dispatching: %d / %d jobs running" , int (d .RunCount ()), cap (d .workerPool ))
225+ if runCountAtLastLog != int (d .RunCount ()) {
226+ _ , _ = d .dispatchLogFn ("during round-robin dispatching: %d / %d jobs running" , int (d .RunCount ()), cap (d .workerPool ))
227+ runCountAtLastLog = int (d .RunCount ())
228+ }
215229
216230 select {
217231 case job := <- d .jobQueue :
0 commit comments