File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -309,15 +309,26 @@ void SupervisedScheduler::runWorker() {
309
309
310
310
{
311
311
std::lock_guard<std::mutex> guard (_mutexSupervisor);
312
- id = _numWorkers++; // increase the number of workers here, to obtains the id
312
+ id = _numWorkers++; // increase the number of workers here, to obtain the id
313
313
// copy shared_ptr with worker state
314
314
state = _workerStates.back ();
315
315
// inform the supervisor that this thread is alive
316
316
_conditionSupervisor.notify_one ();
317
317
}
318
318
319
319
state->_sleepTimeout_ms = 20 * (id + 1 );
320
- state->_queueRetryCount = (512 >> id) + 3 ;
320
+ // cap the timeout to some boundary value
321
+ if (state->_sleepTimeout_ms >= 1000 ) {
322
+ state->_sleepTimeout_ms = 1000 ;
323
+ }
324
+
325
+ if (id < 32 ) {
326
+ // 512 >> 32 => undefined behavior
327
+ state->_queueRetryCount = (512 >> id) + 3 ;
328
+ } else {
329
+ // we want at least 3 retries
330
+ state->_queueRetryCount = 3 ;
331
+ }
321
332
322
333
while (true ) {
323
334
std::unique_ptr<WorkItem> work = getWork (state);
You can’t perform that action at this time.
0 commit comments