aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/surface/init.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lib/surface/init.cc')
-rw-r--r--src/core/lib/surface/init.cc51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc
index 8ee1383fb8..c6ce235da7 100644
--- a/src/core/lib/surface/init.cc
+++ b/src/core/lib/surface/init.cc
@@ -73,14 +73,12 @@ static void do_basic_init(void) {
grpc_fork_handlers_auto_register();
}
-static bool append_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool append_filter(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_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool prepend_filter(grpc_channel_stack_builder* builder, void* arg) {
return grpc_channel_stack_builder_prepend_filter(
builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
}
@@ -123,7 +121,6 @@ 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();
@@ -133,7 +130,8 @@ void grpc_init(void) {
grpc_mdctx_global_init();
grpc_channel_init_init();
grpc_security_pre_init();
- grpc_iomgr_init(&exec_ctx);
+ grpc_core::ExecCtx::GlobalInit();
+ grpc_iomgr_init();
gpr_timers_global_init();
grpc_handshaker_factory_registry_init();
grpc_security_init();
@@ -149,37 +147,44 @@ void grpc_init(void) {
grpc_tracer_init("GRPC_TRACE");
/* no more changes to channel init pipelines */
grpc_channel_init_finalize();
- grpc_iomgr_start(&exec_ctx);
+ grpc_iomgr_start();
}
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, ());
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr);
+ if (grpc_core::ExecCtx::Get()) {
+ grpc_core::ExecCtx::Get()->Flush();
+ }
gpr_mu_lock(&g_init_mu);
if (--g_initializations == 0) {
- 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_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_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_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();
+ grpc_core::ExecCtx::GlobalShutdown();
}
gpr_mu_unlock(&g_init_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
int grpc_is_initialized(void) {