From 84fc2cc78934b549ff5e4b1086b10c8d159241d0 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 8 Mar 2024 09:03:47 -0500 Subject: [PATCH] MT#40962 increase idle sleep time If there are no timers then it makes no senes to process ticks in real time. Sleep up to 0.5 seconds in that case. When timers are added we are immediately woken up through the conditional variable. Only setting the shutdown flag would not wake up the thread, but a sleep time of half a second should be an acceptable delay for shutdowns. Analogous to 695d902841 Change-Id: I37adf078825470af99e6a7755df3d8786d3eeaa6 --- core/sip/wheeltimer.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/sip/wheeltimer.cpp b/core/sip/wheeltimer.cpp index 432082a9..7ee9ab8b 100644 --- a/core/sip/wheeltimer.cpp +++ b/core/sip/wheeltimer.cpp @@ -91,9 +91,13 @@ void _wheeltimer::run() if(now < next_tick){ diff = next_tick - now; - - // Sleep up to diff ms, but wake up early if something is added to reqs_backlog - reqs_cond.wait_for_to(diff / 1000); + + // Sleep up to diff ms OR up to 0.5 seconds if there are no timers, + // but wake up early if something is added to reqs_backlog + if (num_timers) + reqs_cond.wait_for_to(diff / 1000); + else + reqs_cond.wait_for_to(500); // 0.5 s } //else { //printf("missed one tick\n");