diff options
author | 2017-12-06 09:05:05 -0800 | |
---|---|---|
committer | 2017-12-06 09:05:05 -0800 | |
commit | ad4d2dde0052efbbf49d64b0843c45f0381cfeb3 (patch) | |
tree | 6a657f8c6179d873b34505cdc24bce9462ca68eb /src/core/lib/surface/init.cc | |
parent | a3df36cc2505a89c2f481eea4a66a87b3002844a (diff) |
Revert "All instances of exec_ctx being passed around in src/core removed"
Diffstat (limited to 'src/core/lib/surface/init.cc')
-rw-r--r-- | src/core/lib/surface/init.cc | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index c6ce235da7..8ee1383fb8 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -73,12 +73,14 @@ static void do_basic_init(void) { grpc_fork_handlers_auto_register(); } -static bool append_filter(grpc_channel_stack_builder* builder, void* arg) { +static bool append_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, void* arg) { return grpc_channel_stack_builder_append_filter( builder, (const grpc_channel_filter*)arg, nullptr, nullptr); } -static bool prepend_filter(grpc_channel_stack_builder* builder, void* arg) { +static bool prepend_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, void* arg) { return grpc_channel_stack_builder_prepend_filter( builder, (const grpc_channel_filter*)arg, nullptr, nullptr); } @@ -121,6 +123,7 @@ void grpc_init(void) { int i; gpr_once_init(&g_basic_init, do_basic_init); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_mu_lock(&g_init_mu); if (++g_initializations == 1) { gpr_time_init(); @@ -130,8 +133,7 @@ void grpc_init(void) { grpc_mdctx_global_init(); grpc_channel_init_init(); grpc_security_pre_init(); - grpc_core::ExecCtx::GlobalInit(); - grpc_iomgr_init(); + grpc_iomgr_init(&exec_ctx); gpr_timers_global_init(); grpc_handshaker_factory_registry_init(); grpc_security_init(); @@ -147,44 +149,37 @@ void grpc_init(void) { grpc_tracer_init("GRPC_TRACE"); /* no more changes to channel init pipelines */ grpc_channel_init_finalize(); - grpc_iomgr_start(); + grpc_iomgr_start(&exec_ctx); } gpr_mu_unlock(&g_init_mu); - + grpc_exec_ctx_finish(&exec_ctx); GRPC_API_TRACE("grpc_init(void)", 0, ()); } void grpc_shutdown(void) { int i; GRPC_API_TRACE("grpc_shutdown(void)", 0, ()); - if (grpc_core::ExecCtx::Get()) { - grpc_core::ExecCtx::Get()->Flush(); - } + grpc_exec_ctx exec_ctx = + GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr); gpr_mu_lock(&g_init_mu); if (--g_initializations == 0) { - { - grpc_core::ExecCtx exec_ctx(0); - { - grpc_executor_shutdown(); - grpc_timer_manager_set_threading( - false); // shutdown timer_manager thread - for (i = g_number_of_plugins; i >= 0; i--) { - if (g_all_of_the_plugins[i].destroy != nullptr) { - g_all_of_the_plugins[i].destroy(); - } - } + grpc_executor_shutdown(&exec_ctx); + grpc_timer_manager_set_threading(false); // shutdown timer_manager thread + for (i = g_number_of_plugins; i >= 0; i--) { + if (g_all_of_the_plugins[i].destroy != nullptr) { + g_all_of_the_plugins[i].destroy(); } - grpc_iomgr_shutdown(); - gpr_timers_global_destroy(); - grpc_tracer_shutdown(); - grpc_mdctx_global_shutdown(); - grpc_handshaker_factory_registry_shutdown(); - grpc_slice_intern_shutdown(); - grpc_stats_shutdown(); } - grpc_core::ExecCtx::GlobalShutdown(); + grpc_iomgr_shutdown(&exec_ctx); + gpr_timers_global_destroy(); + grpc_tracer_shutdown(); + grpc_mdctx_global_shutdown(&exec_ctx); + grpc_handshaker_factory_registry_shutdown(&exec_ctx); + grpc_slice_intern_shutdown(); + grpc_stats_shutdown(); } gpr_mu_unlock(&g_init_mu); + grpc_exec_ctx_finish(&exec_ctx); } int grpc_is_initialized(void) { |