@ -21,6 +21,7 @@
# include <inttypes.h>
# include "absl/log/check.h"
# include "absl/log/log.h"
# include <grpc/support/alloc.h>
# include <grpc/support/log.h>
@ -89,7 +90,7 @@ static void start_timer_thread_and_unlock(void) {
+ + g_thread_count ;
gpr_mu_unlock ( & g_mu ) ;
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) ) {
gpr_log ( GPR_INFO , " Spawn timer thread " ) ;
LOG ( INFO ) < < " Spawn timer thread " ;
}
completed_thread * ct =
static_cast < completed_thread * > ( gpr_malloc ( sizeof ( * ct ) ) ) ;
@ -125,7 +126,7 @@ static void run_some_timers() {
// waiter so that the next deadline is not missed
if ( ! g_has_timed_waiter ) {
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) ) {
gpr_log ( GPR_INFO , " kick untimed waiter " ) ;
LOG ( INFO ) < < " kick untimed waiter " ;
}
gpr_cv_signal ( & g_cv_wait ) ;
}
@ -133,7 +134,7 @@ static void run_some_timers() {
}
// without our lock, flush the exec_ctx
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) ) {
gpr_log ( GPR_INFO , " flush exec_ctx " ) ;
LOG ( INFO ) < < " flush exec_ctx " ;
}
grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ;
gpr_mu_lock ( & g_mu ) ;
@ -199,7 +200,7 @@ static bool wait_until(grpc_core::Timestamp next) {
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) & &
next = = grpc_core : : Timestamp : : InfFuture ( ) ) {
gpr_log ( GPR_INFO , " sleep until kicked " ) ;
LOG ( INFO ) < < " sleep until kicked " ;
}
gpr_cv_wait ( & g_cv_wait , & g_mu , next . as_timespec ( GPR_CLOCK_MONOTONIC ) ) ;
@ -251,7 +252,7 @@ static void timer_main_loop() {
// Consequently, we can just sleep forever here and be happy at some
// saved wakeup cycles.
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) ) {
gpr_log ( GPR_INFO , " timers not checked: expect another thread to " ) ;
LOG ( INFO ) < < " timers not checked: expect another thread to " ;
}
next = grpc_core : : Timestamp : : InfFuture ( ) ;
ABSL_FALLTHROUGH_INTENDED ;
@ -277,7 +278,7 @@ static void timer_thread_cleanup(completed_thread* ct) {
g_completed_threads = ct ;
gpr_mu_unlock ( & g_mu ) ;
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) ) {
gpr_log ( GPR_INFO , " End timer thread " ) ;
LOG ( INFO ) < < " End timer thread " ;
}
}
@ -318,18 +319,18 @@ void grpc_timer_manager_init(void) {
static void stop_threads ( void ) {
gpr_mu_lock ( & g_mu ) ;
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) ) {
gpr_log ( GPR_INFO , " stop timer threads: threaded=%d " , g_threaded ) ;
LOG ( INFO ) < < " stop timer threads: threaded= " < < g_threaded ;
}
if ( g_threaded ) {
g_threaded = false ;
gpr_cv_broadcast ( & g_cv_wait ) ;
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) ) {
gpr_log ( GPR_INFO , " num timer threads: %d " , g_thread_count ) ;
LOG ( INFO ) < < " num timer threads: " < < g_thread_count ;
}
while ( g_thread_count > 0 ) {
gpr_cv_wait ( & g_cv_shutdown , & g_mu , gpr_inf_future ( GPR_CLOCK_MONOTONIC ) ) ;
if ( GRPC_TRACE_FLAG_ENABLED ( grpc_timer_check_trace ) ) {
gpr_log ( GPR_INFO , " num timer threads: %d " , g_thread_count ) ;
LOG ( INFO ) < < " num timer threads: " < < g_thread_count ;
}
gc_completed_threads ( ) ;
}