diff options
author | 2017-11-22 16:03:32 -0800 | |
---|---|---|
committer | 2017-11-22 16:59:56 -0800 | |
commit | eaf67dbdf67821b76e67066f201f2fafe1f5859c (patch) | |
tree | 5332cad696c25e36868f437b4e1c357c25a550de /src/core/lib | |
parent | a13a8c0f3ea9bdf70680c0c8b5667186c832a412 (diff) |
Fixing errors and minor bugs
Diffstat (limited to 'src/core/lib')
-rw-r--r-- | src/core/lib/iomgr/exec_ctx.cc | 20 | ||||
-rw-r--r-- | src/core/lib/iomgr/exec_ctx.h | 20 | ||||
-rw-r--r-- | src/core/lib/iomgr/pollset_uv.cc | 2 | ||||
-rw-r--r-- | src/core/lib/iomgr/pollset_windows.cc | 2 |
4 files changed, 20 insertions, 24 deletions
diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index 4bd92a4141..25ff686188 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -108,6 +108,13 @@ namespace grpc_core { thread_local ExecCtx* ExecCtx::exec_ctx_ = nullptr; #endif +void ExecCtx::GlobalInit(void) { + g_start_time = gpr_now(GPR_CLOCK_MONOTONIC); +#ifdef GPR_PTHREAD_TLS + gpr_tls_init(&exec_ctx_); +#endif +} + bool ExecCtx::Flush() { bool did_something = 0; GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0); @@ -131,19 +138,6 @@ bool ExecCtx::Flush() { return did_something; } -void ExecCtx::GlobalInit(void) { - g_start_time = gpr_now(GPR_CLOCK_MONOTONIC); -#ifdef GPR_PTHREAD_TLS - gpr_tls_init(&exec_ctx_); -#endif -} - -void ExecCtx::GlobalShutdown(void) { -#ifdef GPR_PTHREAD_TLS - gpr_tls_destroy(&exec_ctx_); -#endif -} - grpc_millis ExecCtx::Now() { if (!now_is_valid_) { now_ = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC)); diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 6320e13acb..6c310a4fd6 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -47,6 +47,12 @@ typedef struct grpc_combiner grpc_combiner; should be given to not delete said call/channel from this exec_ctx */ #define GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP 2 +extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx; + +gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock); +grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec); +grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec); + namespace grpc_core { /** Execution context. * A bag of data that collects information along a callstack. @@ -164,7 +170,11 @@ on outside context */ static void GlobalInit(void); /** Global shutdown for ExecCtx. Called by iomgr */ - static void GlobalShutdown(void); + static void GlobalShutdown(void) { +#ifdef GPR_PTHREAD_TLS + gpr_tls_destroy(&exec_ctx_); +#endif + } /** Gets pointer to current exec_ctx */ static ExecCtx* Get() { @@ -206,14 +216,6 @@ on outside context */ }; } // namespace grpc_core -extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx; - -gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock); -grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec); -grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec); - -void grpc_exec_ctx_maybe_update_start_time(); - #ifdef __cplusplus } #endif diff --git a/src/core/lib/iomgr/pollset_uv.cc b/src/core/lib/iomgr/pollset_uv.cc index d040c0cccb..d9e5ad81be 100644 --- a/src/core/lib/iomgr/pollset_uv.cc +++ b/src/core/lib/iomgr/pollset_uv.cc @@ -139,7 +139,7 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset, uv_run(uv_default_loop(), UV_RUN_NOWAIT); } } - if (!grpc_closure_list_empty(exec_ctx->closure_list)) { + if (!grpc_closure_list_empty(*grpc_core::ExecCtx::Get()->closure_list())) { grpc_core::ExecCtx::Get()->Flush(); } gpr_mu_lock(&grpc_polling_mu); diff --git a/src/core/lib/iomgr/pollset_windows.cc b/src/core/lib/iomgr/pollset_windows.cc index 162037a8da..6ef949aad7 100644 --- a/src/core/lib/iomgr/pollset_windows.cc +++ b/src/core/lib/iomgr/pollset_windows.cc @@ -166,7 +166,7 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset, pollset->kicked_without_pollers = 0; } done: - if (!grpc_closure_list_empty(exec_ctx->closure_list)) { + if (!grpc_closure_list_empty(*grpc_core::ExecCtx::Get()->closure_list())) { gpr_mu_unlock(&grpc_polling_mu); grpc_core::ExecCtx::Get()->Flush(); gpr_mu_lock(&grpc_polling_mu); |