aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-11-13 15:37:58 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2017-11-14 01:36:28 -0800
commit75122c23578e24417dcf64081c737571a9fc2dbc (patch)
treef4b8491964ec0508a5826490628c9f87b82c3326
parent36cd68f0d543b9024c84eff82319890a791de7f6 (diff)
Address some PR comments
-rw-r--r--src/core/ext/filters/client_channel/backup_poller.cc6
-rw-r--r--src/core/ext/filters/client_channel/channel_connectivity.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc8
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc2
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc14
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc2
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc2
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.cc36
-rw-r--r--src/core/ext/filters/max_age/max_age_filter.cc6
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.cc2
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc2
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc1
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.cc6
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc2
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc1
-rw-r--r--src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.cc10
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.cc4
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.cc2
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.cc8
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.cc3
-rw-r--r--src/core/lib/backoff/backoff.cc4
-rw-r--r--src/core/lib/compression/stream_compression_gzip.cc8
-rw-r--r--src/core/lib/debug/stats.h2
-rw-r--r--src/core/lib/iomgr/block_annotate.h23
-rw-r--r--src/core/lib/iomgr/combiner.cc49
-rw-r--r--src/core/lib/iomgr/endpoint_pair_posix.cc1
-rw-r--r--src/core/lib/iomgr/endpoint_pair_windows.cc2
-rw-r--r--src/core/lib/iomgr/error.cc6
-rw-r--r--src/core/lib/iomgr/ev_epoll1_linux.cc24
-rw-r--r--src/core/lib/iomgr/ev_epollex_linux.cc10
-rw-r--r--src/core/lib/iomgr/ev_epollsig_linux.cc8
-rw-r--r--src/core/lib/iomgr/ev_poll_posix.cc10
-rw-r--r--src/core/lib/iomgr/exec_ctx.cc98
-rw-r--r--src/core/lib/iomgr/exec_ctx.h148
-rw-r--r--src/core/lib/iomgr/executor.cc11
-rw-r--r--src/core/lib/iomgr/iocp_windows.cc10
-rw-r--r--src/core/lib/iomgr/iomgr.cc11
-rw-r--r--src/core/lib/iomgr/iomgr_uv.cc1
-rw-r--r--src/core/lib/iomgr/load_file.cc2
-rw-r--r--src/core/lib/iomgr/pollset_uv.cc4
-rw-r--r--src/core/lib/iomgr/pollset_windows.cc8
-rw-r--r--src/core/lib/iomgr/resolve_address_posix.cc4
-rw-r--r--src/core/lib/iomgr/resolve_address_uv.cc2
-rw-r--r--src/core/lib/iomgr/resolve_address_windows.cc2
-rw-r--r--src/core/lib/iomgr/resource_quota.cc2
-rw-r--r--src/core/lib/iomgr/tcp_client_uv.cc3
-rw-r--r--src/core/lib/iomgr/tcp_posix.cc2
-rw-r--r--src/core/lib/iomgr/tcp_server_uv.cc12
-rw-r--r--src/core/lib/iomgr/tcp_uv.cc5
-rw-r--r--src/core/lib/iomgr/timer_generic.cc8
-rw-r--r--src/core/lib/iomgr/timer_manager.cc11
-rw-r--r--src/core/lib/iomgr/timer_uv.cc5
-rw-r--r--src/core/lib/security/context/security_context.cc3
-rw-r--r--src/core/lib/security/credentials/credentials.cc3
-rw-r--r--src/core/lib/security/credentials/google_default/google_default_credentials.cc9
-rw-r--r--src/core/lib/security/credentials/iam/iam_credentials.cc2
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.cc2
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.cc6
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.cc11
-rw-r--r--src/core/lib/security/credentials/plugin/plugin_credentials.cc6
-rw-r--r--src/core/lib/security/transport/security_handshaker.cc1
-rw-r--r--src/core/lib/security/transport/server_auth_filter.cc1
-rw-r--r--src/core/lib/slice/slice.cc1
-rw-r--r--src/core/lib/slice/slice_buffer.cc2
-rw-r--r--src/core/lib/surface/alarm.cc4
-rw-r--r--src/core/lib/surface/byte_buffer.cc1
-rw-r--r--src/core/lib/surface/byte_buffer_reader.cc4
-rw-r--r--src/core/lib/surface/call.cc7
-rw-r--r--src/core/lib/surface/call_details.cc1
-rw-r--r--src/core/lib/surface/channel.cc9
-rw-r--r--src/core/lib/surface/channel_ping.cc1
-rw-r--r--src/core/lib/surface/completion_queue.cc138
-rw-r--r--src/core/lib/surface/init.cc5
-rw-r--r--src/core/lib/surface/lame_client.cc2
-rw-r--r--src/core/lib/surface/server.cc15
-rw-r--r--src/core/lib/transport/bdp_estimator.cc2
-rw-r--r--src/core/lib/transport/status_conversion.cc4
-rw-r--r--src/core/lib/transport/transport.cc2
-rw-r--r--src/cpp/common/channel_arguments.cc3
-rw-r--r--test/core/backoff/backoff_test.cc51
-rw-r--r--test/core/bad_client/bad_client.cc9
-rw-r--r--test/core/channel/channel_args_test.cc4
-rw-r--r--test/core/channel/channel_stack_test.cc3
-rw-r--r--test/core/channel/minimal_stack_is_minimal_test.cc2
-rw-r--r--test/core/client_channel/lb_policies_test.cc2
-rw-r--r--test/core/client_channel/parse_address_test.cc3
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc6
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_test.cc3
-rw-r--r--test/core/client_channel/resolvers/fake_resolver_test.cc8
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.cc4
-rw-r--r--test/core/client_channel/uri_fuzzer_test.cc2
-rw-r--r--test/core/client_channel/uri_parser_test.cc8
-rw-r--r--test/core/compression/algorithm_test.cc2
-rw-r--r--test/core/compression/message_compress_test.cc9
-rw-r--r--test/core/debug/stats_test.cc3
-rw-r--r--test/core/end2end/bad_server_response_test.cc2
-rw-r--r--test/core/end2end/connection_refused_test.cc1
-rw-r--r--test/core/end2end/fixtures/h2_census.cc2
-rw-r--r--test/core/end2end/fixtures/h2_compress.cc3
-rw-r--r--test/core/end2end/fixtures/h2_fd.cc4
-rw-r--r--test/core/end2end/fixtures/h2_full+workarounds.cc1
-rw-r--r--test/core/end2end/fixtures/h2_load_reporting.cc1
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.cc1
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.cc4
-rw-r--r--test/core/end2end/fixtures/h2_sockpair.cc3
-rw-r--r--test/core/end2end/fixtures/h2_sockpair_1byte.cc3
-rw-r--r--test/core/end2end/fixtures/h2_ssl.cc1
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.cc2
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc15
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc10
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.cc2
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.cc2
-rw-r--r--test/core/end2end/h2_ssl_cert_test.cc1
-rw-r--r--test/core/end2end/tests/cancel_after_accept.cc1
-rw-r--r--test/core/end2end/tests/cancel_after_round_trip.cc1
-rw-r--r--test/core/end2end/tests/compressed_payload.cc3
-rw-r--r--test/core/end2end/tests/load_reporting_hook.cc1
-rw-r--r--test/core/end2end/tests/max_message_length.cc2
-rw-r--r--test/core/end2end/tests/stream_compression_compressed_payload.cc3
-rw-r--r--test/core/end2end/tests/stream_compression_payload.cc1
-rw-r--r--test/core/end2end/tests/stream_compression_ping_pong_streaming.cc1
-rw-r--r--test/core/end2end/tests/workaround_cronet_compression.cc2
-rw-r--r--test/core/http/httpcli_test.cc6
-rw-r--r--test/core/http/httpscli_test.cc6
-rw-r--r--test/core/iomgr/combiner_test.cc11
-rw-r--r--test/core/iomgr/endpoint_pair_test.cc3
-rw-r--r--test/core/iomgr/endpoint_tests.cc16
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc23
-rw-r--r--test/core/iomgr/fd_conservation_posix_test.cc3
-rw-r--r--test/core/iomgr/fd_posix_test.cc16
-rw-r--r--test/core/iomgr/pollset_set_test.cc32
-rw-r--r--test/core/iomgr/resolve_address_posix_test.cc11
-rw-r--r--test/core/iomgr/resolve_address_test.cc33
-rw-r--r--test/core/iomgr/resource_quota_test.cc86
-rw-r--r--test/core/iomgr/tcp_client_posix_test.cc13
-rw-r--r--test/core/iomgr/tcp_client_uv_test.cc11
-rw-r--r--test/core/iomgr/tcp_posix_test.cc20
-rw-r--r--test/core/iomgr/tcp_server_posix_test.cc11
-rw-r--r--test/core/iomgr/tcp_server_uv_test.cc9
-rw-r--r--test/core/iomgr/timer_list_test.cc28
-rw-r--r--test/core/iomgr/udp_server_test.cc13
-rw-r--r--test/core/security/credentials_test.cc46
-rw-r--r--test/core/security/json_token_test.cc4
-rw-r--r--test/core/security/jwt_verifier_test.cc20
-rw-r--r--test/core/security/oauth2_utils.cc4
-rw-r--r--test/core/security/print_google_default_creds_token.cc4
-rw-r--r--test/core/security/secure_endpoint_test.cc8
-rw-r--r--test/core/security/ssl_server_fuzzer.cc8
-rw-r--r--test/core/security/verify_jwt.cc4
-rw-r--r--test/core/slice/b64_test.cc5
-rw-r--r--test/core/slice/slice_hash_table_test.cc3
-rw-r--r--test/core/surface/byte_buffer_reader_test.cc1
-rw-r--r--test/core/surface/channel_create_test.cc1
-rw-r--r--test/core/surface/completion_queue_test.cc4
-rw-r--r--test/core/surface/completion_queue_threading_test.cc3
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc7
-rw-r--r--test/core/surface/lame_client_test.cc2
-rw-r--r--test/core/surface/num_external_connectivity_watchers_test.cc1
-rw-r--r--test/core/surface/secure_channel_create_test.cc3
-rw-r--r--test/core/surface/sequential_connectivity_test.cc1
-rw-r--r--test/core/transport/bdp_estimator_test.cc3
-rw-r--r--test/core/transport/byte_stream_test.cc5
-rw-r--r--test/core/transport/chttp2/bin_decoder_test.cc2
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.cc1
-rw-r--r--test/core/transport/chttp2/hpack_parser_fuzzer_test.cc2
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.cc3
-rw-r--r--test/core/transport/chttp2/hpack_table_test.cc5
-rw-r--r--test/core/transport/connectivity_state_test.cc14
-rw-r--r--test/core/transport/metadata_test.cc15
-rw-r--r--test/core/transport/status_conversion_test.cc2
-rw-r--r--test/core/util/port_server_client.cc18
-rw-r--r--test/core/util/test_tcp_server.cc5
-rw-r--r--test/cpp/end2end/client_lb_end2end_test.cc1
-rw-r--r--test/cpp/end2end/grpclb_end2end_test.cc1
-rw-r--r--test/cpp/grpclb/grpclb_test.cc1
-rw-r--r--test/cpp/microbenchmarks/bm_call_create.cc7
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc20
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_transport.cc13
-rw-r--r--test/cpp/microbenchmarks/bm_closure.cc65
-rw-r--r--test/cpp/microbenchmarks/bm_cq.cc6
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc2
-rw-r--r--test/cpp/microbenchmarks/bm_error.cc6
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_trickle.cc2
-rw-r--r--test/cpp/microbenchmarks/bm_metadata.cc26
-rw-r--r--test/cpp/microbenchmarks/bm_pollset.cc12
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h2
-rw-r--r--test/cpp/naming/resolver_component_test.cc6
-rw-r--r--test/cpp/performance/writes_per_rpc_test.cc2
192 files changed, 700 insertions, 1091 deletions
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc
index 1b42f5d6a0..dbdcd53ef5 100644
--- a/src/core/ext/filters/client_channel/backup_poller.cc
+++ b/src/core/ext/filters/client_channel/backup_poller.cc
@@ -112,10 +112,10 @@ static void run_poller(void* arg, grpc_error* error) {
backup_poller_shutdown_unref(p);
return;
}
- grpc_error* err = grpc_pollset_work(p->pollset, NULL, grpc_exec_ctx_now());
+ grpc_error* err = grpc_pollset_work(p->pollset, NULL, ExecCtx::Get()->Now());
gpr_mu_unlock(p->pollset_mu);
GRPC_LOG_IF_ERROR("Run client channel backup poller", err);
- grpc_timer_init(&p->polling_timer, grpc_exec_ctx_now() + g_poll_interval_ms,
+ grpc_timer_init(&p->polling_timer, ExecCtx::Get()->Now() + g_poll_interval_ms,
&p->run_poller_closure);
}
@@ -137,7 +137,7 @@ void grpc_client_channel_start_backup_polling(
GRPC_CLOSURE_INIT(&g_poller->run_poller_closure, run_poller, g_poller,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&g_poller->polling_timer,
- grpc_exec_ctx_now() + g_poll_interval_ms,
+ ExecCtx::Get()->Now() + g_poll_interval_ms,
&g_poller->run_poller_closure);
}
diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc
index 3069e66775..0ceedb9f86 100644
--- a/src/core/ext/filters/client_channel/channel_connectivity.cc
+++ b/src/core/ext/filters/client_channel/channel_connectivity.cc
@@ -41,14 +41,14 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
if (client_channel_elem->filter == &grpc_client_channel_filter) {
state = grpc_client_channel_check_connectivity_state(client_channel_elem,
try_to_connect);
- grpc_exec_ctx_finish();
+
return state;
}
gpr_log(GPR_ERROR,
"grpc_channel_check_connectivity_state called on something that is "
"not a client channel, but '%s'",
client_channel_elem->filter->name);
- grpc_exec_ctx_finish();
+
return GRPC_CHANNEL_SHUTDOWN;
}
@@ -241,6 +241,4 @@ void grpc_channel_watch_connectivity_state(
} else {
abort();
}
-
- grpc_exec_ctx_finish();
}
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
index d4c58fb1e0..63cf417c4e 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
@@ -1122,7 +1122,7 @@ static void start_picking_locked(glb_lb_policy* glb_policy) {
if (glb_policy->lb_fallback_timeout_ms > 0 &&
glb_policy->serverlist == NULL && !glb_policy->fallback_timer_active) {
grpc_millis deadline =
- grpc_exec_ctx_now() + glb_policy->lb_fallback_timeout_ms;
+ ExecCtx::Get()->Now() + glb_policy->lb_fallback_timeout_ms;
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "grpclb_fallback_timer");
GRPC_CLOSURE_INIT(&glb_policy->lb_on_fallback, lb_on_fallback_timer_locked,
glb_policy,
@@ -1271,7 +1271,7 @@ static void maybe_restart_lb_call(glb_lb_policy* glb_policy) {
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_DEBUG, "[grpclb %p] Connection to LB server lost...",
glb_policy);
- grpc_millis timeout = next_try - grpc_exec_ctx_now();
+ grpc_millis timeout = next_try - ExecCtx::Get()->Now();
if (timeout > 0) {
gpr_log(GPR_DEBUG,
"[grpclb %p] ... retry_timer_active in %" PRIuPTR "ms.",
@@ -1297,7 +1297,7 @@ static void send_client_load_report_locked(void* arg, grpc_error* error);
static void schedule_next_client_load_report(glb_lb_policy* glb_policy) {
const grpc_millis next_client_load_report_time =
- grpc_exec_ctx_now() + glb_policy->client_stats_report_interval;
+ ExecCtx::Get()->Now() + glb_policy->client_stats_report_interval;
GRPC_CLOSURE_INIT(&glb_policy->client_load_report_closure,
send_client_load_report_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner));
@@ -1392,7 +1392,7 @@ static void lb_call_init_locked(glb_lb_policy* glb_policy) {
grpc_millis deadline =
glb_policy->lb_call_timeout_ms == 0
? GRPC_MILLIS_INF_FUTURE
- : grpc_exec_ctx_now() + glb_policy->lb_call_timeout_ms;
+ : ExecCtx::Get()->Now() + glb_policy->lb_call_timeout_ms;
glb_policy->lb_call = grpc_channel_create_pollset_set_call(
glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS,
glb_policy->base.interested_parties,
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
index 77d790aa38..f0543964ae 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
@@ -265,7 +265,7 @@ static void dns_ares_on_resolved_locked(void* arg, grpc_error* error) {
gpr_log(GPR_DEBUG, "dns resolution failed: %s", msg);
grpc_millis next_try =
grpc_backoff_step(&r->backoff_state).next_attempt_start_time;
- grpc_millis timeout = next_try - grpc_exec_ctx_now();
+ grpc_millis timeout = next_try - ExecCtx::Get()->Now();
gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
grpc_error_string(error));
GPR_ASSERT(!r->have_retry_timer);
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
index c57fac61a4..925223d189 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
@@ -101,18 +101,7 @@ static void grpc_ares_request_unref(grpc_ares_request* r) {
request */
if (gpr_unref(&r->pending_queries)) {
/* TODO(zyc): Sort results with RFC6724 before invoking on_done. */
- if (exec_ctx == NULL) {
- /* A new exec_ctx is created here, as the c-ares interface does not
- provide one in ares_host_callback. It's safe to schedule on_done with
- the newly created exec_ctx, since the caller has been warned not to
- acquire locks in on_done. ares_dns_resolver is using combiner to
- protect resources needed by on_done. */
- ExecCtx _local_exec_ctx;
- GRPC_CLOSURE_SCHED(r->on_done, r->error);
- grpc_exec_ctx_finish();
- } else {
- GRPC_CLOSURE_SCHED(r->on_done, r->error);
- }
+ GRPC_CLOSURE_SCHED(r->on_done, r->error);
gpr_mu_destroy(&r->mu);
grpc_ares_ev_driver_destroy(r->ev_driver);
gpr_free(r);
@@ -263,7 +252,6 @@ static void on_srv_query_done_cb(void* arg, int status, int timeouts,
}
}
grpc_ares_request_unref(r);
- grpc_exec_ctx_finish();
}
static const char g_service_config_attribute_prefix[] = "grpc_config=";
diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
index 4463673e1f..10404ec4ef 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
@@ -163,7 +163,7 @@ static void dns_on_resolved_locked(void* arg, grpc_error* error) {
} else {
grpc_millis next_try =
grpc_backoff_step(&r->backoff_state).next_attempt_start_time;
- grpc_millis timeout = next_try - grpc_exec_ctx_now();
+ grpc_millis timeout = next_try - ExecCtx::Get()->Now();
gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
grpc_error_string(error));
GPR_ASSERT(!r->have_retry_timer);
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
index c8583687d5..98f96b5750 100644
--- a/src/core/ext/filters/client_channel/subchannel.cc
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -458,7 +458,7 @@ static void maybe_start_connecting_locked(grpc_subchannel* c) {
GPR_ASSERT(!c->have_alarm);
c->have_alarm = true;
const grpc_millis time_til_next =
- c->backoff_result.next_attempt_start_time - grpc_exec_ctx_now();
+ c->backoff_result.next_attempt_start_time - ExecCtx::Get()->Now();
if (time_til_next <= 0) {
gpr_log(GPR_INFO, "Retry immediately");
} else {
diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc
index cb8e480734..fbab57769c 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.cc
+++ b/src/core/ext/filters/client_channel/subchannel_index.cc
@@ -132,10 +132,8 @@ void grpc_subchannel_index_shutdown(void) {
void grpc_subchannel_index_unref(void) {
if (gpr_unref(&g_refcount)) {
- ExecCtx _local_exec_ctx;
gpr_mu_destroy(&g_mu);
- gpr_avl_unref(g_subchannel_index, exec_ctx);
- grpc_exec_ctx_finish();
+ gpr_avl_unref(g_subchannel_index, ExecCtx::Get());
}
}
@@ -145,12 +143,12 @@ grpc_subchannel* grpc_subchannel_index_find(grpc_subchannel_key* key) {
// Lock, and take a reference to the subchannel index.
// We don't need to do the search under a lock as avl's are immutable.
gpr_mu_lock(&g_mu);
- gpr_avl index = gpr_avl_ref(g_subchannel_index, exec_ctx);
+ gpr_avl index = gpr_avl_ref(g_subchannel_index, ExecCtx::Get());
gpr_mu_unlock(&g_mu);
grpc_subchannel* c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(
- (grpc_subchannel*)gpr_avl_get(index, key, exec_ctx), "index_find");
- gpr_avl_unref(index, exec_ctx);
+ (grpc_subchannel*)gpr_avl_get(index, key, ExecCtx::Get()), "index_find");
+ gpr_avl_unref(index, ExecCtx::Get());
return c;
}
@@ -166,11 +164,11 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
// Compare and swap loop:
// - take a reference to the current index
gpr_mu_lock(&g_mu);
- gpr_avl index = gpr_avl_ref(g_subchannel_index, exec_ctx);
+ gpr_avl index = gpr_avl_ref(g_subchannel_index, ExecCtx::Get());
gpr_mu_unlock(&g_mu);
// - Check to see if a subchannel already exists
- c = (grpc_subchannel*)gpr_avl_get(index, key, exec_ctx);
+ c = (grpc_subchannel*)gpr_avl_get(index, key, ExecCtx::Get());
if (c != NULL) {
c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(c, "index_register");
}
@@ -180,8 +178,9 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
} else {
// no -> update the avl and compare/swap
gpr_avl updated = gpr_avl_add(
- gpr_avl_ref(index, exec_ctx), subchannel_key_copy(key),
- GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"), exec_ctx);
+ gpr_avl_ref(index, ExecCtx::Get()), subchannel_key_copy(key),
+ GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"),
+ ExecCtx::Get());
// it may happen (but it's expected to be unlikely)
// that some other thread has changed the index:
@@ -193,9 +192,9 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
}
gpr_mu_unlock(&g_mu);
- gpr_avl_unref(updated, exec_ctx);
+ gpr_avl_unref(updated, ExecCtx::Get());
}
- gpr_avl_unref(index, exec_ctx);
+ gpr_avl_unref(index, ExecCtx::Get());
}
if (need_to_unref_constructed) {
@@ -212,21 +211,22 @@ void grpc_subchannel_index_unregister(grpc_subchannel_key* key,
// Compare and swap loop:
// - take a reference to the current index
gpr_mu_lock(&g_mu);
- gpr_avl index = gpr_avl_ref(g_subchannel_index, exec_ctx);
+ gpr_avl index = gpr_avl_ref(g_subchannel_index, ExecCtx::Get());
gpr_mu_unlock(&g_mu);
// Check to see if this key still refers to the previously
// registered subchannel
- grpc_subchannel* c = (grpc_subchannel*)gpr_avl_get(index, key, exec_ctx);
+ grpc_subchannel* c =
+ (grpc_subchannel*)gpr_avl_get(index, key, ExecCtx::Get());
if (c != constructed) {
- gpr_avl_unref(index, exec_ctx);
+ gpr_avl_unref(index, ExecCtx::Get());
break;
}
// compare and swap the update (some other thread may have
// mutated the index behind us)
gpr_avl updated =
- gpr_avl_remove(gpr_avl_ref(index, exec_ctx), key, exec_ctx);
+ gpr_avl_remove(gpr_avl_ref(index, ExecCtx::Get()), key, ExecCtx::Get());
gpr_mu_lock(&g_mu);
if (index.root == g_subchannel_index.root) {
@@ -235,8 +235,8 @@ void grpc_subchannel_index_unregister(grpc_subchannel_key* key,
}
gpr_mu_unlock(&g_mu);
- gpr_avl_unref(updated, exec_ctx);
- gpr_avl_unref(index, exec_ctx);
+ gpr_avl_unref(updated, ExecCtx::Get());
+ gpr_avl_unref(index, ExecCtx::Get());
}
}
diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc
index 1b9ce3b996..015a3ce124 100644
--- a/src/core/ext/filters/max_age/max_age_filter.cc
+++ b/src/core/ext/filters/max_age/max_age_filter.cc
@@ -100,7 +100,7 @@ static void decrease_call_count(channel_data* chand) {
if (gpr_atm_full_fetch_add(&chand->call_count, -1) == 1) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_idle_timer");
grpc_timer_init(&chand->max_idle_timer,
- grpc_exec_ctx_now() + chand->max_connection_idle,
+ ExecCtx::Get()->Now() + chand->max_connection_idle,
&chand->close_max_idle_channel);
}
}
@@ -121,7 +121,7 @@ static void start_max_age_timer_after_init(void* arg, grpc_error* error) {
chand->max_age_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_timer");
grpc_timer_init(&chand->max_age_timer,
- grpc_exec_ctx_now() + chand->max_connection_age,
+ ExecCtx::Get()->Now() + chand->max_connection_age,
&chand->close_max_age_channel);
gpr_mu_unlock(&chand->max_age_timer_mu);
grpc_transport_op* op = grpc_make_transport_op(NULL);
@@ -141,7 +141,7 @@ static void start_max_age_grace_timer_after_goaway_op(void* arg,
grpc_timer_init(&chand->max_age_grace_timer,
chand->max_connection_age_grace == GRPC_MILLIS_INF_FUTURE
? GRPC_MILLIS_INF_FUTURE
- : grpc_exec_ctx_now() + chand->max_connection_age_grace,
+ : ExecCtx::Get()->Now() + chand->max_connection_age_grace,
&chand->force_close_max_age_channel);
gpr_mu_unlock(&chand->max_age_timer_mu);
GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
index e7741f97d4..3afca884ca 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -95,7 +95,7 @@ grpc_channel* grpc_insecure_channel_create(const char* target,
new_args);
// Clean up.
grpc_channel_args_destroy(new_args);
- grpc_exec_ctx_finish();
+
return channel != NULL ? channel
: grpc_lame_client_channel_create(
target, GRPC_STATUS_INTERNAL,
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
index 37e6f1f30d..b0eff1c992 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
@@ -60,8 +60,6 @@ grpc_channel* grpc_insecure_channel_create_from_fd(
grpc_channel_args_destroy(final_args);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
-
return channel != NULL ? channel
: grpc_lame_client_channel_create(
target, GRPC_STATUS_INTERNAL,
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
index a5da71a67c..bebc38c248 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
@@ -211,7 +211,6 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
new_args);
// Clean up.
grpc_channel_args_destroy(new_args);
- grpc_exec_ctx_finish();
}
return channel != NULL ? channel
: grpc_lame_client_channel_create(
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc
index 6eb1e3491c..bbcfb1b195 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.cc
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc
@@ -132,7 +132,7 @@ static void on_accept(void* arg, grpc_endpoint* tcp,
connection_state->handshake_mgr);
// TODO(roth): We should really get this timeout value from channel
// args instead of hard-coding it.
- const grpc_millis deadline = grpc_exec_ctx_now() + 120 * GPR_MS_PER_SEC;
+ const grpc_millis deadline = ExecCtx::Get()->Now() + 120 * GPR_MS_PER_SEC;
grpc_handshake_manager_do_handshake(connection_state->handshake_mgr, tcp,
state->args, deadline, acceptor,
on_handshake_done, connection_state);
@@ -161,10 +161,10 @@ static void tcp_server_shutdown_complete(void* arg, grpc_error* error) {
gpr_mu_unlock(&state->mu);
// Flush queued work before destroying handshaker factory, since that
// may do a synchronous unref.
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
if (destroy_done != NULL) {
destroy_done->cb(destroy_done->cb_arg, GRPC_ERROR_REF(error));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
grpc_channel_args_destroy(state->args);
gpr_mu_destroy(&state->mu);
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
index d7aad110b9..6cbb26a349 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
@@ -39,6 +39,6 @@ int grpc_server_add_insecure_http2_port(grpc_server* server, const char* addr) {
GRPC_ERROR_UNREF(err);
}
- grpc_exec_ctx_finish();
+
return port_num;
}
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
index 57a8316a58..e5419e5e6e 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
@@ -61,7 +61,6 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
grpc_server_setup_transport(server, transport, NULL, server_args);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
}
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
index dc7da96210..aeae8f42e3 100644
--- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
+++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
@@ -76,7 +76,7 @@ done:
if (sc != NULL) {
GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "server");
}
- grpc_exec_ctx_finish();
+
if (err != GRPC_ERROR_NONE) {
const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
index ecf3cf69ef..e49e26fc35 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
@@ -530,7 +530,7 @@ static void init_transport(grpc_chttp2_transport* t,
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
grpc_timer_init(&t->keepalive_ping_timer,
- grpc_exec_ctx_now() + t->keepalive_time,
+ ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
} else {
/* Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no
@@ -2585,14 +2585,14 @@ static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
} else {
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
grpc_timer_init(&t->keepalive_ping_timer,
- grpc_exec_ctx_now() + t->keepalive_time,
+ ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
}
} else if (error == GRPC_ERROR_CANCELLED) {
/* The keepalive ping timer may be cancelled by bdp */
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
grpc_timer_init(&t->keepalive_ping_timer,
- grpc_exec_ctx_now() + t->keepalive_time,
+ ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
}
GRPC_CHTTP2_UNREF_TRANSPORT(t, "init keepalive ping");
@@ -2602,7 +2602,7 @@ static void start_keepalive_ping_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog");
grpc_timer_init(&t->keepalive_watchdog_timer,
- grpc_exec_ctx_now() + t->keepalive_time,
+ ExecCtx::Get()->Now() + t->keepalive_time,
&t->keepalive_watchdog_fired_locked);
}
@@ -2614,7 +2614,7 @@ static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
grpc_timer_cancel(&t->keepalive_watchdog_timer);
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
grpc_timer_init(&t->keepalive_ping_timer,
- grpc_exec_ctx_now() + t->keepalive_time,
+ ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
}
}
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc
index 1609fa0532..e54d59b5fa 100644
--- a/src/core/ext/transport/chttp2/transport/flow_control.cc
+++ b/src/core/ext/transport/chttp2/transport/flow_control.cc
@@ -160,7 +160,7 @@ TransportFlowControl::TransportFlowControl(const grpc_chttp2_transport* t,
.set_min_control_value(-1)
.set_max_control_value(25)
.set_integral_range(10)),
- last_pid_update_(grpc_exec_ctx_now()) {}
+ last_pid_update_(ExecCtx::Get()->Now()) {}
uint32_t TransportFlowControl::MaybeSendUpdate(bool writing_anyway) {
FlowControlTrace trace("t updt sent", this, nullptr);
@@ -306,7 +306,7 @@ double TransportFlowControl::TargetLogBdp() {
}
double TransportFlowControl::SmoothLogBdp(double value) {
- grpc_millis now = grpc_exec_ctx_now();
+ grpc_millis now = ExecCtx::Get()->Now();
double bdp_error = value - pid_controller_.last_control_value();
const double dt = (double)(now - last_pid_update_) * 1e-3;
last_pid_update_ = now;
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc
index 1b0dc0dfaa..60172be9cb 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc
@@ -89,7 +89,7 @@ grpc_error* grpc_chttp2_ping_parser_parse(void* parser,
grpc_chttp2_ack_ping(t, p->opaque_8bytes);
} else {
if (!t->is_client) {
- grpc_millis now = grpc_exec_ctx_now();
+ grpc_millis now = ExecCtx::Get()->Now();
grpc_millis next_allowed_ping =
t->ping_recv_state.last_ping_recv_time +
t->ping_policy.min_recv_ping_interval_without_data;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
index e225a0244a..efb6e54ce7 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
@@ -570,7 +570,7 @@ static void deadline_enc(grpc_chttp2_hpack_compressor* c, grpc_millis deadline,
framer_state* st) {
char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
grpc_mdelem mdelem;
- grpc_http2_encode_timeout(deadline - grpc_exec_ctx_now(), timeout_str);
+ grpc_http2_encode_timeout(deadline - ExecCtx::Get()->Now(), timeout_str);
mdelem = grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_TIMEOUT,
grpc_slice_from_copied_string(timeout_str));
hpack_enc(c, mdelem, st);
diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc
index 5731e9ff78..f7f83c9aee 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.cc
+++ b/src/core/ext/transport/chttp2/transport/parsing.cc
@@ -436,7 +436,7 @@ static void on_initial_header(void* tp, grpc_mdelem md) {
}
if (timeout != GRPC_MILLIS_INF_FUTURE) {
grpc_chttp2_incoming_metadata_buffer_set_deadline(
- &s->metadata_buffer[0], grpc_exec_ctx_now() + timeout);
+ &s->metadata_buffer[0], ExecCtx::Get()->Now() + timeout);
}
GRPC_MDELEM_UNREF(md);
} else {
diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc
index ec83633472..4f76c2eb23 100644
--- a/src/core/ext/transport/chttp2/transport/writing.cc
+++ b/src/core/ext/transport/chttp2/transport/writing.cc
@@ -68,7 +68,7 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) {
}
return;
}
- grpc_millis now = grpc_exec_ctx_now();
+ grpc_millis now = ExecCtx::Get()->Now();
grpc_millis next_allowed_ping =
t->ping_state.last_ping_sent_time +
t->ping_policy.min_sent_ping_interval_without_data;
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc
index bff0fb36ad..3411acc563 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.cc
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc
@@ -417,7 +417,6 @@ static void on_failed(bidirectional_stream* stream, int net_error) {
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
- grpc_exec_ctx_finish();
}
/*
@@ -444,7 +443,6 @@ static void on_canceled(bidirectional_stream* stream) {
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
- grpc_exec_ctx_finish();
}
/*
@@ -463,7 +461,6 @@ static void on_succeeded(bidirectional_stream* stream) {
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
- grpc_exec_ctx_finish();
}
/*
@@ -492,7 +489,6 @@ static void on_stream_ready(bidirectional_stream* stream) {
}
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
- grpc_exec_ctx_finish();
}
/*
@@ -548,7 +544,6 @@ static void on_response_headers_received(
}
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
- grpc_exec_ctx_finish();
}
/*
@@ -566,7 +561,6 @@ static void on_write_completed(bidirectional_stream* stream, const char* data) {
s->state.state_callback_received[OP_SEND_MESSAGE] = true;
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
- grpc_exec_ctx_finish();
}
/*
@@ -608,7 +602,6 @@ static void on_read_completed(bidirectional_stream* stream, char* data,
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
}
- grpc_exec_ctx_finish();
}
/*
@@ -666,7 +659,6 @@ static void on_response_trailers_received(
gpr_mu_unlock(&s->mu);
execute_from_storage(s);
}
- grpc_exec_ctx_finish();
}
/*
diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc
index 1c7f2873d1..a79b2b26b0 100644
--- a/src/core/ext/transport/inproc/inproc_transport.cc
+++ b/src/core/ext/transport/inproc/inproc_transport.cc
@@ -1107,7 +1107,6 @@ void grpc_inproc_transport_init(void) {
grpc_slice_unref_internal(auth_tmp);
g_fake_auth_value = grpc_slice_from_static_string("inproc-fail");
- grpc_exec_ctx_finish();
}
static const grpc_transport_vtable inproc_vtable = {
@@ -1182,7 +1181,6 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
grpc_channel_args_destroy(client_args);
// Now finish scheduled operations
- grpc_exec_ctx_finish();
return channel;
}
@@ -1194,5 +1192,4 @@ void grpc_inproc_transport_shutdown(void) {
grpc_slice_unref_internal(g_fake_path_value);
grpc_slice_unref_internal(g_fake_auth_key);
grpc_slice_unref_internal(g_fake_auth_value);
- grpc_exec_ctx_finish();
}
diff --git a/src/core/lib/backoff/backoff.cc b/src/core/lib/backoff/backoff.cc
index e6c55f420d..b75ce79d46 100644
--- a/src/core/lib/backoff/backoff.cc
+++ b/src/core/lib/backoff/backoff.cc
@@ -36,7 +36,7 @@ grpc_backoff_result grpc_backoff_begin(grpc_backoff* backoff) {
backoff->current_backoff = backoff->initial_backoff;
const grpc_millis initial_timeout =
GPR_MAX(backoff->initial_backoff, backoff->min_connect_timeout);
- const grpc_millis now = grpc_exec_ctx_now();
+ const grpc_millis now = ExecCtx::Get()->Now();
const grpc_backoff_result result = {now + initial_timeout,
now + backoff->current_backoff};
return result;
@@ -67,7 +67,7 @@ grpc_backoff_result grpc_backoff_step(grpc_backoff* backoff) {
backoff->min_connect_timeout);
const grpc_millis next_timeout = GPR_MIN(
(grpc_millis)(backoff->current_backoff + jitter), backoff->max_backoff);
- const grpc_millis now = grpc_exec_ctx_now();
+ const grpc_millis now = ExecCtx::Get()->Now();
const grpc_backoff_result result = {now + current_timeout,
now + next_timeout};
return result;
diff --git a/src/core/lib/compression/stream_compression_gzip.cc b/src/core/lib/compression/stream_compression_gzip.cc
index 4d5d0955ce..3fae3490ce 100644
--- a/src/core/lib/compression/stream_compression_gzip.cc
+++ b/src/core/lib/compression/stream_compression_gzip.cc
@@ -58,7 +58,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
if (r < 0 && r != Z_BUF_ERROR) {
gpr_log(GPR_ERROR, "zlib error (%d)", r);
grpc_slice_unref_internal(slice_out);
- grpc_exec_ctx_finish();
+
return false;
} else if (r == Z_STREAM_END && ctx->flate == inflate) {
eoc = true;
@@ -89,7 +89,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
default:
gpr_log(GPR_ERROR, "zlib error (%d)", r);
grpc_slice_unref_internal(slice_out);
- grpc_exec_ctx_finish();
+
return false;
}
} else if (flush == Z_FINISH) {
@@ -105,7 +105,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
default:
gpr_log(GPR_ERROR, "zlib error (%d)", r);
grpc_slice_unref_internal(slice_out);
- grpc_exec_ctx_finish();
+
return false;
}
}
@@ -121,7 +121,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
}
max_output_size -= (slice_size - ctx->zs.avail_out);
}
- grpc_exec_ctx_finish();
+
if (end_of_context) {
*end_of_context = eoc;
}
diff --git a/src/core/lib/debug/stats.h b/src/core/lib/debug/stats.h
index 1c2826506c..24b0084130 100644
--- a/src/core/lib/debug/stats.h
+++ b/src/core/lib/debug/stats.h
@@ -35,7 +35,7 @@ typedef struct grpc_stats_data {
extern grpc_stats_data* grpc_stats_per_cpu_storage;
#define GRPC_THREAD_STATS_DATA() \
- (&grpc_stats_per_cpu_storage[(exec_ctx)->starting_cpu])
+ (&grpc_stats_per_cpu_storage[ExecCtx::Get()->starting_cpu()])
#define GRPC_STATS_INC_COUNTER(ctr) \
(gpr_atm_no_barrier_fetch_add(&GRPC_THREAD_STATS_DATA()->counters[(ctr)], 1))
diff --git a/src/core/lib/iomgr/block_annotate.h b/src/core/lib/iomgr/block_annotate.h
index 9db3cf0199..7783da0c14 100644
--- a/src/core/lib/iomgr/block_annotate.h
+++ b/src/core/lib/iomgr/block_annotate.h
@@ -19,6 +19,8 @@
#ifndef GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
#define GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
+#include "src/core/lib/iomgr/exec_ctx.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -39,25 +41,18 @@ void gpr_thd_end_blocking_region();
do { \
gpr_thd_start_blocking_region(); \
} while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \
- do { \
- gpr_thd_end_blocking_region(); \
- } while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX() \
- do { \
- gpr_thd_end_blocking_region(); \
- grpc_exec_ctx_invalidate_now(); \
+#define GRPC_SCHEDULING_END_BLOCKING_REGION \
+ do { \
+ gpr_thd_end_blocking_region(); \
+ ExecCtx::Get()->InvalidateNow(); \
} while (0)
#else
#define GRPC_SCHEDULING_START_BLOCKING_REGION \
do { \
} while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \
- do { \
- } while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX() \
- do { \
- grpc_exec_ctx_invalidate_now(); \
+#define GRPC_SCHEDULING_END_BLOCKING_REGION \
+ do { \
+ ExecCtx::Get()->InvalidateNow(); \
} while (0)
#endif
diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc
index b1b8fffdca..c9f5448630 100644
--- a/src/core/lib/iomgr/combiner.cc
+++ b/src/core/lib/iomgr/combiner.cc
@@ -128,20 +128,24 @@ grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
}
static void push_last_on_exec_ctx(grpc_combiner* lock) {
- lock->next_combiner_on_this_exec_ctx = NULL;
- if (exec_ctx->active_combiner == NULL) {
- exec_ctx->active_combiner = exec_ctx->last_combiner = lock;
+ lock->next_combiner_on_this_exec_ctx = nullptr;
+ if (ExecCtx::Get()->combiner_data()->active_combiner == nullptr) {
+ ExecCtx::Get()->combiner_data()->active_combiner =
+ ExecCtx::Get()->combiner_data()->last_combiner = lock;
} else {
- exec_ctx->last_combiner->next_combiner_on_this_exec_ctx = lock;
- exec_ctx->last_combiner = lock;
+ ExecCtx::Get()
+ ->combiner_data()
+ ->last_combiner->next_combiner_on_this_exec_ctx = lock;
+ ExecCtx::Get()->combiner_data()->last_combiner = lock;
}
}
static void push_first_on_exec_ctx(grpc_combiner* lock) {
- lock->next_combiner_on_this_exec_ctx = exec_ctx->active_combiner;
- exec_ctx->active_combiner = lock;
+ lock->next_combiner_on_this_exec_ctx =
+ ExecCtx::Get()->combiner_data()->active_combiner;
+ ExecCtx::Get()->combiner_data()->active_combiner = lock;
if (lock->next_combiner_on_this_exec_ctx == NULL) {
- exec_ctx->last_combiner = lock;
+ ExecCtx::Get()->combiner_data()->last_combiner = lock;
}
}
@@ -161,7 +165,7 @@ static void combiner_exec(grpc_closure* cl, grpc_error* error) {
GRPC_STATS_INC_COMBINER_LOCKS_INITIATED();
GPR_TIMER_MARK("combiner.initiated", 0);
gpr_atm_no_barrier_store(&lock->initiating_exec_ctx_or_null,
- (gpr_atm)exec_ctx);
+ (gpr_atm)ExecCtx::Get());
// first element on this list: add it to the list of combiner locks
// executing within this exec_ctx
push_last_on_exec_ctx(lock);
@@ -170,7 +174,7 @@ static void combiner_exec(grpc_closure* cl, grpc_error* error) {
// offload for one or two actions, and that's fine
gpr_atm initiator =
gpr_atm_no_barrier_load(&lock->initiating_exec_ctx_or_null);
- if (initiator != 0 && initiator != (gpr_atm)exec_ctx) {
+ if (initiator != 0 && initiator != (gpr_atm)ExecCtx::Get()) {
gpr_atm_no_barrier_store(&lock->initiating_exec_ctx_or_null, 0);
}
}
@@ -182,10 +186,12 @@ static void combiner_exec(grpc_closure* cl, grpc_error* error) {
}
static void move_next() {
- exec_ctx->active_combiner =
- exec_ctx->active_combiner->next_combiner_on_this_exec_ctx;
- if (exec_ctx->active_combiner == NULL) {
- exec_ctx->last_combiner = NULL;
+ ExecCtx::Get()->combiner_data()->active_combiner =
+ ExecCtx::Get()
+ ->combiner_data()
+ ->active_combiner->next_combiner_on_this_exec_ctx;
+ if (ExecCtx::Get()->combiner_data()->active_combiner == NULL) {
+ ExecCtx::Get()->combiner_data()->last_combiner = NULL;
}
}
@@ -203,7 +209,7 @@ static void queue_offload(grpc_combiner* lock) {
bool grpc_combiner_continue_exec_ctx() {
GPR_TIMER_BEGIN("combiner.continue_exec_ctx", 0);
- grpc_combiner* lock = exec_ctx->active_combiner;
+ grpc_combiner* lock = ExecCtx::Get()->combiner_data()->active_combiner;
if (lock == NULL) {
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return false;
@@ -217,10 +223,11 @@ bool grpc_combiner_continue_exec_ctx() {
"contended=%d "
"exec_ctx_ready_to_finish=%d "
"time_to_execute_final_list=%d",
- lock, contended, grpc_exec_ctx_ready_to_finish(),
+ lock, contended,
+ ExecCtx::Get()->IsReadyToFinish(),
lock->time_to_execute_final_list));
- if (contended && grpc_exec_ctx_ready_to_finish() &&
+ if (contended && ExecCtx::Get()->IsReadyToFinish() &&
grpc_executor_is_threaded()) {
GPR_TIMER_MARK("offload_from_finished_exec_ctx", 0);
// this execution context wants to move on: schedule remaining work to be
@@ -326,11 +333,11 @@ static void combiner_finally_exec(grpc_closure* closure, grpc_error* error) {
GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS();
grpc_combiner* lock =
COMBINER_FROM_CLOSURE_SCHEDULER(closure, finally_scheduler);
- GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG,
- "C:%p grpc_combiner_execute_finally c=%p; ac=%p",
- lock, closure, exec_ctx->active_combiner));
+ GRPC_COMBINER_TRACE(
+ gpr_log(GPR_DEBUG, "C:%p grpc_combiner_execute_finally c=%p; ac=%p", lock,
+ closure, ExecCtx::Get()->combiner_data()->active_combiner));
GPR_TIMER_BEGIN("combiner.execute_finally", 0);
- if (exec_ctx->active_combiner != lock) {
+ if (ExecCtx::Get()->combiner_data()->active_combiner != lock) {
GPR_TIMER_MARK("slowpath", 0);
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(enqueue_finally, closure,
grpc_combiner_scheduler(lock)),
diff --git a/src/core/lib/iomgr/endpoint_pair_posix.cc b/src/core/lib/iomgr/endpoint_pair_posix.cc
index 696ac6942f..1a281322a8 100644
--- a/src/core/lib/iomgr/endpoint_pair_posix.cc
+++ b/src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -65,7 +65,6 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name,
"socketpair-client");
gpr_free(final_name);
- grpc_exec_ctx_finish();
return p;
}
diff --git a/src/core/lib/iomgr/endpoint_pair_windows.cc b/src/core/lib/iomgr/endpoint_pair_windows.cc
index d464617097..e0f211cdf9 100644
--- a/src/core/lib/iomgr/endpoint_pair_windows.cc
+++ b/src/core/lib/iomgr/endpoint_pair_windows.cc
@@ -77,7 +77,7 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(
channel_args, "endpoint:server");
p.server = grpc_tcp_create(grpc_winsocket_create(sv[0], "endpoint:server"),
channel_args, "endpoint:client");
- grpc_exec_ctx_finish();
+
return p;
}
diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc
index ce8b538773..157f12a36d 100644
--- a/src/core/lib/iomgr/error.cc
+++ b/src/core/lib/iomgr/error.cc
@@ -157,11 +157,7 @@ static void unref_errs(grpc_error* err) {
}
}
-static void unref_slice(grpc_slice slice) {
- ExecCtx _local_exec_ctx;
- grpc_slice_unref_internal(slice);
- grpc_exec_ctx_finish();
-}
+static void unref_slice(grpc_slice slice) { grpc_slice_unref_internal(slice); }
static void unref_strs(grpc_error* err) {
for (size_t which = 0; which < GRPC_ERROR_STR_MAX; ++which) {
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc
index 31f51df15d..2b486887b8 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.cc
+++ b/src/core/lib/iomgr/ev_epoll1_linux.cc
@@ -554,7 +554,7 @@ static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
static int poll_deadline_to_millis_timeout(grpc_millis millis) {
if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
- grpc_millis delta = millis - grpc_exec_ctx_now();
+ grpc_millis delta = millis - ExecCtx::Get()->Now();
if (delta > INT_MAX) {
return INT_MAX;
} else if (delta < 0) {
@@ -630,7 +630,7 @@ static grpc_error* do_epoll_wait(grpc_pollset* ps, grpc_millis deadline) {
timeout);
} while (r < 0 && errno == EINTR);
if (timeout != 0) {
- GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX();
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
}
if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait");
@@ -743,7 +743,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
SET_KICK_STATE(worker, KICKED);
}
}
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
}
if (GRPC_TRACER_ON(grpc_polling_trace)) {
@@ -848,7 +848,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
/* Make sure we appear kicked */
SET_KICK_STATE(worker, KICKED);
grpc_closure_list_move(&worker->schedule_on_end_work,
- &exec_ctx->closure_list);
+ ExecCtx::Get()->closure_list());
if (gpr_atm_no_barrier_load(&g_active_poller) == (gpr_atm)worker) {
if (worker->next != worker && worker->next->state == UNKICKED) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
@@ -859,9 +859,9 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
SET_KICK_STATE(worker->next, DESIGNATED_POLLER);
GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&worker->next->cv);
- if (grpc_exec_ctx_has_work()) {
+ if (ExecCtx::Get()->HasWork()) {
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
} else {
@@ -892,12 +892,12 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
found_worker = check_neighborhood_for_available_poller(neighborhood);
gpr_mu_unlock(&neighborhood->mu);
}
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
- } else if (grpc_exec_ctx_has_work()) {
+ } else if (ExecCtx::Get()->HasWork()) {
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
if (worker->initialized_cv) {
@@ -948,9 +948,9 @@ static grpc_error* pollset_work(grpc_pollset* ps,
process_epoll_events() returns very quickly: It just queues the work on
exec_ctx but does not execute it (the actual exectution or more
- accurately grpc_exec_ctx_flush() happens in end_worker() AFTER selecting
- a designated poller). So we are not waiting long periods without a
- designated poller */
+ accurately ExecCtx::Get()->Flush() happens in end_worker() AFTER
+ selecting a designated poller). So we are not waiting long periods
+ without a designated poller */
if (gpr_atm_acq_load(&g_epoll_set.cursor) ==
gpr_atm_acq_load(&g_epoll_set.num_events)) {
append_error(&error, do_epoll_wait(ps, deadline), err_desc);
diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc
index 0979a45270..385b5f68d0 100644
--- a/src/core/lib/iomgr/ev_epollex_linux.cc
+++ b/src/core/lib/iomgr/ev_epollex_linux.cc
@@ -682,7 +682,7 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
static int poll_deadline_to_millis_timeout(grpc_millis millis) {
if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
- grpc_millis delta = millis - grpc_exec_ctx_now();
+ grpc_millis delta = millis - ExecCtx::Get()->Now();
if (delta > INT_MAX)
return INT_MAX;
else if (delta < 0)
@@ -804,7 +804,7 @@ static grpc_error* pollable_epoll(pollable* p, grpc_millis deadline) {
r = epoll_wait(p->epfd, p->events, MAX_EPOLL_EVENTS, timeout);
} while (r < 0 && errno == EINTR);
if (timeout != 0) {
- GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX();
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
}
if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait");
@@ -902,7 +902,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
worker->pollable_obj, worker);
}
}
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
} else {
gpr_mu_unlock(&pollset->mu);
}
@@ -970,7 +970,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
gpr_log(GPR_DEBUG,
"PS:%p work hdl=%p worker=%p now=%" PRIdPTR " deadline=%" PRIdPTR
" kwp=%d pollable=%p",
- pollset, worker_hdl, WORKER_PTR, grpc_exec_ctx_now(), deadline,
+ pollset, worker_hdl, WORKER_PTR, ExecCtx::Get()->Now(), deadline,
pollset->kicked_without_poller, pollset->active_pollable);
}
static const char* err_desc = "pollset_work";
@@ -990,7 +990,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
&error,
pollable_process_events(pollset, WORKER_PTR->pollable_obj, false),
err_desc);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_tls_set(&g_current_thread_pollset, 0);
gpr_tls_set(&g_current_thread_worker, 0);
}
diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc
index c42a609fee..a9b094a2fa 100644
--- a/src/core/lib/iomgr/ev_epollsig_linux.cc
+++ b/src/core/lib/iomgr/ev_epollsig_linux.cc
@@ -1090,7 +1090,7 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
static int poll_deadline_to_millis_timeout(grpc_millis millis) {
if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
- grpc_millis delta = millis - grpc_exec_ctx_now();
+ grpc_millis delta = millis - ExecCtx::Get()->Now();
if (delta > INT_MAX)
return INT_MAX;
else if (delta < 0)
@@ -1220,7 +1220,7 @@ static void pollset_work_and_unlock(grpc_pollset* pollset,
GRPC_STATS_INC_SYSCALL_POLL();
ep_rv =
epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask);
- GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX();
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
if (ep_rv < 0) {
if (errno != EINTR) {
gpr_asprintf(&err_msg,
@@ -1350,7 +1350,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
pollset_work_and_unlock(pollset, &worker, timeout_ms, &g_orig_sigmask,
&error);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->po.mu);
@@ -1373,7 +1373,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
finish_shutdown_locked(pollset);
gpr_mu_unlock(&pollset->po.mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->po.mu);
}
diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc
index c7189950f0..cab4f7547c 100644
--- a/src/core/lib/iomgr/ev_poll_posix.cc
+++ b/src/core/lib/iomgr/ev_poll_posix.cc
@@ -976,7 +976,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
GRPC_SCHEDULING_START_BLOCKING_REGION;
GRPC_STATS_INC_SYSCALL_POLL();
r = grpc_poll_function(pfds, pfd_count, timeout);
- GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX();
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "%p poll=%d", pollset, r);
@@ -1040,7 +1040,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
worker list, which means nobody could ask us to re-evaluate polling). */
done:
if (!locked) {
- queued_work |= grpc_exec_ctx_flush();
+ queued_work |= ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
locked = 1;
}
@@ -1074,7 +1074,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
pollset->called_shutdown = 1;
gpr_mu_unlock(&pollset->mu);
finish_shutdown(pollset);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Continuing to access pollset here is safe -- it is the caller's
* responsibility to not destroy when it has outstanding calls to
* pollset_work.
@@ -1083,7 +1083,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
} else if (!grpc_closure_list_empty(pollset->idle_jobs)) {
GRPC_CLOSURE_LIST_SCHED(&pollset->idle_jobs);
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
}
@@ -1110,7 +1110,7 @@ static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
static int poll_deadline_to_millis_timeout(grpc_millis deadline) {
if (deadline == GRPC_MILLIS_INF_FUTURE) return -1;
if (deadline == 0) return 0;
- grpc_millis n = deadline - grpc_exec_ctx_now();
+ grpc_millis n = deadline - ExecCtx::Get()->Now();
if (n < 0) return 0;
if (n > INT_MAX) return -1;
return (int)n;
diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc
index c10d1e60f0..fe5a0e7e2d 100644
--- a/src/core/lib/iomgr/exec_ctx.cc
+++ b/src/core/lib/iomgr/exec_ctx.cc
@@ -27,45 +27,19 @@
thread_local ExecCtx* exec_ctx = nullptr;
-ExecCtx::ExecCtx()
- : closure_list(GRPC_CLOSURE_LIST_INIT),
- active_combiner(nullptr),
- last_combiner(nullptr),
- flags(GRPC_EXEC_CTX_FLAG_IS_FINISHED),
- starting_cpu(gpr_cpu_current_cpu()),
- check_ready_to_finish_arg(nullptr),
- check_ready_to_finish(nullptr),
- now_is_valid(false),
- now(0),
- last_exec_ctx(exec_ctx) {
- exec_ctx = this;
-}
-
-ExecCtx::ExecCtx(uintptr_t fl, bool (*finish_check)(void* arg),
- void* finish_check_arg)
- : closure_list(GRPC_CLOSURE_LIST_INIT),
- active_combiner(nullptr),
- last_combiner(nullptr),
- flags(fl),
- starting_cpu(gpr_cpu_current_cpu()),
- check_ready_to_finish_arg(finish_check_arg),
- check_ready_to_finish(finish_check),
- now_is_valid(false),
- now(0),
- last_exec_ctx(exec_ctx) {
- exec_ctx = this;
-}
-
+ExecCtx::ExecCtx() : flags_(GRPC_EXEC_CTX_FLAG_IS_FINISHED) { exec_ctx = this; }
+ExecCtx::ExecCtx(uintptr_t fl) : flags_(fl) { exec_ctx = this; }
ExecCtx::~ExecCtx() {
GPR_ASSERT(exec_ctx == this);
- grpc_exec_ctx_finish();
- exec_ctx = last_exec_ctx;
+ flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
+ Flush();
+ exec_ctx = last_exec_ctx_;
}
-bool grpc_exec_ctx_ready_to_finish() {
- if ((exec_ctx->flags & GRPC_EXEC_CTX_FLAG_IS_FINISHED) == 0) {
- if (exec_ctx->check_ready_to_finish(exec_ctx->check_ready_to_finish_arg)) {
- exec_ctx->flags |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
+bool ExecCtx::IsReadyToFinish() {
+ if ((flags_ & GRPC_EXEC_CTX_FLAG_IS_FINISHED) == 0) {
+ if (CheckReadyToFinish()) {
+ flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
return true;
}
return false;
@@ -74,21 +48,7 @@ bool grpc_exec_ctx_ready_to_finish() {
}
}
-bool grpc_never_ready_to_finish(void* arg_ignored) { return false; }
-
-bool grpc_always_ready_to_finish(void* arg_ignored) { return true; }
-
-bool grpc_exec_ctx_has_work() {
- return exec_ctx->active_combiner != NULL ||
- !grpc_closure_list_empty(exec_ctx->closure_list);
-}
-
-void grpc_exec_ctx_finish() {
- exec_ctx->flags |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
- grpc_exec_ctx_flush();
-}
-
-static void exec_ctx_run(grpc_closure* closure, grpc_error* error) {
+void exec_ctx_run(grpc_closure* closure, grpc_error* error) {
#ifndef NDEBUG
closure->scheduled = false;
if (GRPC_TRACER_ON(grpc_trace_closure)) {
@@ -107,13 +67,13 @@ static void exec_ctx_run(grpc_closure* closure, grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
-bool grpc_exec_ctx_flush() {
+bool ExecCtx::Flush() {
bool did_something = 0;
GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
for (;;) {
- if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
- grpc_closure* c = exec_ctx->closure_list.head;
- exec_ctx->closure_list.head = exec_ctx->closure_list.tail = NULL;
+ if (!grpc_closure_list_empty(closure_list_)) {
+ grpc_closure* c = closure_list_.head;
+ closure_list_.head = closure_list_.tail = NULL;
while (c != NULL) {
grpc_closure* next = c->next_data.next;
grpc_error* error = c->error_data.error;
@@ -125,13 +85,13 @@ bool grpc_exec_ctx_flush() {
break;
}
}
- GPR_ASSERT(exec_ctx->active_combiner == NULL);
+ GPR_ASSERT(combiner_data_.active_combiner == nullptr);
GPR_TIMER_END("grpc_exec_ctx_flush", 0);
return did_something;
}
-static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) {
- grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
+void exec_ctx_sched(grpc_closure* closure, grpc_error* error) {
+ grpc_closure_list_append(exec_ctx->closure_list(), closure, error);
}
static gpr_timespec
@@ -139,7 +99,7 @@ static gpr_timespec
// last enum value in
// gpr_clock_type
-void grpc_exec_ctx_global_init(void) {
+void ExecCtx::GlobalInit(void) {
for (int i = 0; i < GPR_TIMESPAN; i++) {
g_start_time[i] = gpr_now((gpr_clock_type)i);
}
@@ -147,7 +107,7 @@ void grpc_exec_ctx_global_init(void) {
g_start_time[GPR_TIMESPAN] = gpr_time_0(GPR_TIMESPAN);
}
-void grpc_exec_ctx_global_shutdown(void) {}
+void ExecCtx::GlobalShutdown(void) {}
static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) {
ts = gpr_time_sub(ts, g_start_time[ts.clock_type]);
@@ -168,16 +128,6 @@ static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) {
return (gpr_atm)x;
}
-grpc_millis grpc_exec_ctx_now() {
- if (!exec_ctx->now_is_valid) {
- exec_ctx->now = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC));
- exec_ctx->now_is_valid = true;
- }
- return exec_ctx->now;
-}
-
-void grpc_exec_ctx_invalidate_now() { exec_ctx->now_is_valid = false; }
-
gpr_timespec grpc_millis_to_timespec(grpc_millis millis,
gpr_clock_type clock_type) {
// special-case infinities as grpc_millis can be 32bit on some platforms
@@ -204,6 +154,16 @@ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) {
return timespec_to_atm_round_up(ts);
}
+grpc_millis ExecCtx::Now() {
+ if (!now_is_valid_) {
+ now_ = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC));
+ now_is_valid_ = true;
+ }
+ return now_;
+}
+
+ExecCtx* ExecCtx::Get() { return exec_ctx; }
+
static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = {
exec_ctx_run, exec_ctx_sched, "exec_ctx"};
static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable};
diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h
index a80bcbbc0d..a71e43e178 100644
--- a/src/core/lib/iomgr/exec_ctx.h
+++ b/src/core/lib/iomgr/exec_ctx.h
@@ -66,95 +66,81 @@ typedef struct grpc_combiner grpc_combiner;
* - Instances are always passed as the first argument to a function that
* takes it, and always as a pointer (grpc_exec_ctx is never copied).
*/
-struct grpc_exec_ctx {
- grpc_closure_list closure_list;
- /** currently active combiner: updated only via combiner.c */
- grpc_combiner* active_combiner;
- /** last active combiner in the active combiner list */
- grpc_combiner* last_combiner;
- uintptr_t flags;
- unsigned starting_cpu;
- void* check_ready_to_finish_arg;
- bool (*check_ready_to_finish)(void* arg);
-
- bool now_is_valid;
- grpc_millis now;
- const char* creator;
-};
-
-extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;
-
-bool grpc_exec_ctx_has_work();
-
-/** Flush any work that has been enqueued onto this grpc_exec_ctx.
- * Caller must guarantee that no interfering locks are held.
- * Returns true if work was performed, false otherwise. */
-bool grpc_exec_ctx_flush();
-/** Finish any pending work for a grpc_exec_ctx. Must be called before
- * the instance is destroyed, or work may be lost. */
-void grpc_exec_ctx_finish();
-/** Returns true if we'd like to leave this execution context as soon as
- possible: useful for deciding whether to do something more or not depending
- on outside context */
-bool grpc_exec_ctx_ready_to_finish();
-/** A finish check that is never ready to finish */
-bool grpc_never_ready_to_finish(void* arg_ignored);
-/** A finish check that is always ready to finish */
-bool grpc_always_ready_to_finish(void* arg_ignored);
-
-void grpc_exec_ctx_global_init(void);
-
-void grpc_exec_ctx_global_init(void);
-void grpc_exec_ctx_global_shutdown(void);
-
-grpc_millis grpc_exec_ctx_now();
-void grpc_exec_ctx_invalidate_now();
-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);
-
-inline grpc_exec_ctx make_exec_ctx(grpc_exec_ctx r) {
- grpc_exec_ctx_flush();
- return r;
-}
-
class ExecCtx {
public:
ExecCtx();
- ExecCtx(uintptr_t fl, bool (*finish_check)(void* arg),
- void* finish_check_arg);
+ ExecCtx(uintptr_t fl);
~ExecCtx();
- grpc_closure_list closure_list;
- /** currently active combiner: updated only via combiner.c */
- grpc_combiner* active_combiner;
- /** last active combiner in the active combiner list */
- grpc_combiner* last_combiner;
- uintptr_t flags;
- unsigned starting_cpu;
- void* check_ready_to_finish_arg;
- bool (*check_ready_to_finish)(void* arg);
-
- bool now_is_valid;
- grpc_millis now;
-
- private:
- ExecCtx* last_exec_ctx;
-};
+ unsigned starting_cpu() const { return starting_cpu_; }
+
+ struct CombinerData {
+ /* currently active combiner: updated only via combiner.c */
+ grpc_combiner* active_combiner;
+ /* last active combiner in the active combiner list */
+ grpc_combiner* last_combiner;
+ };
+
+ /** Only to be used by grpc-combiner code */
+ CombinerData* combiner_data() { return &combiner_data_; }
+
+ grpc_closure_list* closure_list() { return &closure_list_; }
+
+ bool HasWork() {
+ return combiner_data_.active_combiner != NULL ||
+ !grpc_closure_list_empty(closure_list_);
+ }
+
+ /** Flush any work that has been enqueued onto this grpc_exec_ctx.
+ * Caller must guarantee that no interfering locks are held.
+ * Returns true if work was performed, false otherwise. */
+ bool Flush();
+
+ /** Returns true if we'd like to leave this execution context as soon as
+possible: useful for deciding whether to do something more or not depending
+on outside context */
+ bool IsReadyToFinish();
-extern thread_local ExecCtx* exec_ctx;
+ grpc_millis Now();
-/* initializer for grpc_exec_ctx:
- * prefer to use GRPC_EXEC_CTX_INIT whenever possible */
-#define GRPC_EXEC_CTX_INITIALIZER(flags, finish_check, finish_check_arg) \
- make_exec_ctx(grpc_exec_ctx{GRPC_CLOSURE_LIST_INIT, NULL, NULL, flags, \
- gpr_cpu_current_cpu(), finish_check_arg, \
- finish_check, false, 0, __PRETTY_FUNCTION__})
+ void InvalidateNow() { now_is_valid_ = false; }
-/* initialize an execution context at the top level of an API call into grpc
- (this is safe to use elsewhere, though possibly not as efficient) */
-#define GRPC_EXEC_CTX_INIT \
- GRPC_EXEC_CTX_INITIALIZER(GRPC_EXEC_CTX_FLAG_IS_FINISHED, NULL, NULL)
+ void SetNow(grpc_millis new_val) {
+ now_ = new_val;
+ now_is_valid_ = true;
+ }
+
+ uintptr_t flags() { return flags_; }
+
+ /** Finish any pending work for a grpc_exec_ctx. Must be called before
+ * the instance is destroyed, or work may be lost. */
+ void Finish();
+
+ static void GlobalInit(void);
+
+ static void GlobalShutdown(void);
+
+ static ExecCtx* Get();
+
+ protected:
+ virtual bool CheckReadyToFinish() { return false; }
+
+ grpc_closure_list closure_list_ = GRPC_CLOSURE_LIST_INIT;
+ CombinerData combiner_data_ = {nullptr, nullptr};
+ uintptr_t flags_;
+ unsigned starting_cpu_ = gpr_cpu_current_cpu();
+
+ bool now_is_valid_ = false;
+ grpc_millis now_ = 0;
+
+ ExecCtx* last_exec_ctx_ = Get();
+};
+
+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);
#ifdef __cplusplus
}
diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc
index f764d915ff..bf8805a2cd 100644
--- a/src/core/lib/iomgr/executor.cc
+++ b/src/core/lib/iomgr/executor.cc
@@ -78,7 +78,7 @@ static size_t run_closures(grpc_closure_list list) {
GRPC_ERROR_UNREF(error);
c = next;
n++;
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
return n;
@@ -145,7 +145,7 @@ static void executor_thread(void* arg) {
thread_state* ts = (thread_state*)arg;
gpr_tls_set(&g_this_thread_state, (intptr_t)ts);
- ExecCtx _local_exec_ctx(0, grpc_never_ready_to_finish, NULL);
+ ExecCtx _local_exec_ctx;
size_t subtract_depth = 0;
for (;;) {
@@ -175,10 +175,9 @@ static void executor_thread(void* arg) {
gpr_log(GPR_DEBUG, "EXECUTOR[%d]: execute", (int)(ts - g_thread_state));
}
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
subtract_depth = run_closures(exec);
}
- grpc_exec_ctx_finish();
}
static void executor_push(grpc_closure* closure, grpc_error* error,
@@ -201,12 +200,12 @@ static void executor_push(grpc_closure* closure, grpc_error* error,
gpr_log(GPR_DEBUG, "EXECUTOR: schedule %p inline", closure);
#endif
}
- grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
+ grpc_closure_list_append(ExecCtx::Get()->closure_list(), closure, error);
return;
}
thread_state* ts = (thread_state*)gpr_tls_get(&g_this_thread_state);
if (ts == NULL) {
- ts = &g_thread_state[GPR_HASH_POINTER(exec_ctx, cur_thread_count)];
+ ts = &g_thread_state[GPR_HASH_POINTER(ExecCtx::Get(), cur_thread_count)];
} else {
GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF();
}
diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc
index 8f15f5e6cc..1686bf2872 100644
--- a/src/core/lib/iomgr/iocp_windows.cc
+++ b/src/core/lib/iomgr/iocp_windows.cc
@@ -46,7 +46,7 @@ static DWORD deadline_to_millis_timeout(grpc_millis deadline) {
if (deadline == GRPC_MILLIS_INF_FUTURE) {
return INFINITE;
}
- grpc_millis now = grpc_exec_ctx_now();
+ grpc_millis now = ExecCtx::Get()->Now();
if (deadline < now) return 0;
grpc_millis timeout = deadline - now;
if (timeout > std::numeric_limits<DWORD>::max()) return INFINITE;
@@ -65,7 +65,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_millis deadline) {
success =
GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped,
deadline_to_millis_timeout(deadline));
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
if (success == 0 && overlapped == NULL) {
return GRPC_IOCP_WORK_TIMEOUT;
}
@@ -118,16 +118,16 @@ void grpc_iocp_flush(void) {
do {
work_status = grpc_iocp_work(GRPC_MILLIS_INF_PAST);
- } while (work_status == GRPC_IOCP_WORK_KICK || grpc_exec_ctx_flush());
+ } while (work_status == GRPC_IOCP_WORK_KICK || ExecCtx::Get()->Flush());
}
void grpc_iocp_shutdown(void) {
ExecCtx _local_exec_ctx;
while (gpr_atm_acq_load(&g_custom_events)) {
grpc_iocp_work(GRPC_MILLIS_INF_FUTURE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
GPR_ASSERT(CloseHandle(g_iocp));
}
diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc
index 01d9964cc8..a1add4a303 100644
--- a/src/core/lib/iomgr/iomgr.cc
+++ b/src/core/lib/iomgr/iomgr.cc
@@ -49,7 +49,7 @@ void grpc_iomgr_init() {
g_shutdown = 0;
gpr_mu_init(&g_mu);
gpr_cv_init(&g_rcv);
- grpc_exec_ctx_global_init();
+ ExecCtx::GlobalInit();
grpc_executor_init();
grpc_timer_list_init();
g_root_object.next = g_root_object.prev = &g_root_object;
@@ -98,11 +98,10 @@ void grpc_iomgr_shutdown() {
}
last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
}
- exec_ctx->now_is_valid = true;
- exec_ctx->now = GRPC_MILLIS_INF_FUTURE;
+ ExecCtx::Get()->SetNow(GRPC_MILLIS_INF_FUTURE);
if (grpc_timer_check(NULL) == GRPC_TIMERS_FIRED) {
gpr_mu_unlock(&g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_iomgr_platform_flush();
gpr_mu_lock(&g_mu);
continue;
@@ -137,14 +136,14 @@ void grpc_iomgr_shutdown() {
gpr_mu_unlock(&g_mu);
grpc_timer_list_shutdown();
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* ensure all threads have left g_mu */
gpr_mu_lock(&g_mu);
gpr_mu_unlock(&g_mu);
grpc_iomgr_platform_shutdown();
- grpc_exec_ctx_global_shutdown();
+ ExecCtx::GlobalShutdown();
grpc_network_status_shutdown();
gpr_mu_destroy(&g_mu);
gpr_cv_destroy(&g_rcv);
diff --git a/src/core/lib/iomgr/iomgr_uv.cc b/src/core/lib/iomgr/iomgr_uv.cc
index 4dda970286..2ab414252a 100644
--- a/src/core/lib/iomgr/iomgr_uv.cc
+++ b/src/core/lib/iomgr/iomgr_uv.cc
@@ -34,7 +34,6 @@ void grpc_iomgr_platform_init(void) {
grpc_register_tracer(&grpc_tcp_trace);
grpc_executor_set_threading(false);
g_init_thread = gpr_thd_currentid();
- grpc_exec_ctx_finish();
}
void grpc_iomgr_platform_flush(void) {}
void grpc_iomgr_platform_shutdown(void) { grpc_pollset_global_shutdown(); }
diff --git a/src/core/lib/iomgr/load_file.cc b/src/core/lib/iomgr/load_file.cc
index 97e448fb32..feef65cc34 100644
--- a/src/core/lib/iomgr/load_file.cc
+++ b/src/core/lib/iomgr/load_file.cc
@@ -73,6 +73,6 @@ end:
GRPC_ERROR_UNREF(error);
error = error_out;
}
- GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
return error;
}
diff --git a/src/core/lib/iomgr/pollset_uv.cc b/src/core/lib/iomgr/pollset_uv.cc
index 7028876297..a68ad4a6e3 100644
--- a/src/core/lib/iomgr/pollset_uv.cc
+++ b/src/core/lib/iomgr/pollset_uv.cc
@@ -124,7 +124,7 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset,
GRPC_UV_ASSERT_SAME_THREAD();
gpr_mu_unlock(&grpc_polling_mu);
if (grpc_pollset_work_run_loop) {
- grpc_millis now = grpc_exec_ctx_now();
+ grpc_millis now = ExecCtx::Get()->Now();
if (deadline >= now) {
timeout = deadline - now;
} else {
@@ -143,7 +143,7 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset,
}
}
if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
gpr_mu_lock(&grpc_polling_mu);
return GRPC_ERROR_NONE;
diff --git a/src/core/lib/iomgr/pollset_windows.cc b/src/core/lib/iomgr/pollset_windows.cc
index dd019b1ec3..5ff3e7cb3a 100644
--- a/src/core/lib/iomgr/pollset_windows.cc
+++ b/src/core/lib/iomgr/pollset_windows.cc
@@ -129,7 +129,7 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset,
g_active_poller = &worker;
gpr_mu_unlock(&grpc_polling_mu);
grpc_iocp_work(deadline);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&grpc_polling_mu);
pollset->is_iocp_worker = 0;
g_active_poller = NULL;
@@ -160,10 +160,10 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset,
while (!worker.kicked) {
if (gpr_cv_wait(&worker.cv, &grpc_polling_mu,
grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) {
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
break;
}
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
}
} else {
pollset->kicked_without_pollers = 0;
@@ -171,7 +171,7 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset,
done:
if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
gpr_mu_unlock(&grpc_polling_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&grpc_polling_mu);
}
if (added_worker) {
diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc
index 3795c3f75e..80a1a45cc0 100644
--- a/src/core/lib/iomgr/resolve_address_posix.cc
+++ b/src/core/lib/iomgr/resolve_address_posix.cc
@@ -81,7 +81,7 @@ static grpc_error* blocking_resolve_address_impl(
GRPC_SCHEDULING_START_BLOCKING_REGION;
s = getaddrinfo(host, port, &hints, &result);
- GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
if (s != 0) {
/* Retry if well-known service name is recognized */
@@ -90,7 +90,7 @@ static grpc_error* blocking_resolve_address_impl(
if (strcmp(port, svc[i][0]) == 0) {
GRPC_SCHEDULING_START_BLOCKING_REGION;
s = getaddrinfo(host, svc[i][1], &hints, &result);
- GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
break;
}
}
diff --git a/src/core/lib/iomgr/resolve_address_uv.cc b/src/core/lib/iomgr/resolve_address_uv.cc
index 038926af07..ffd70c4f35 100644
--- a/src/core/lib/iomgr/resolve_address_uv.cc
+++ b/src/core/lib/iomgr/resolve_address_uv.cc
@@ -131,7 +131,7 @@ static void getaddrinfo_callback(uv_getaddrinfo_t* req, int status,
original error probably has more interesting information */
error = handle_addrinfo_result(status, res, r->addresses);
GRPC_CLOSURE_SCHED(r->on_done, error);
- grpc_exec_ctx_finish();
+
gpr_free(r->hints);
gpr_free(r->host);
gpr_free(r->port);
diff --git a/src/core/lib/iomgr/resolve_address_windows.cc b/src/core/lib/iomgr/resolve_address_windows.cc
index 15f3fd9f1a..4e2bc7b5ca 100644
--- a/src/core/lib/iomgr/resolve_address_windows.cc
+++ b/src/core/lib/iomgr/resolve_address_windows.cc
@@ -87,7 +87,7 @@ static grpc_error* blocking_resolve_address_impl(
GRPC_SCHEDULING_START_BLOCKING_REGION;
s = getaddrinfo(host, port, &hints, &result);
- GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
if (s != 0) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo");
goto done;
diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc
index b58ae1cb21..8fee585f4b 100644
--- a/src/core/lib/iomgr/resource_quota.cc
+++ b/src/core/lib/iomgr/resource_quota.cc
@@ -624,7 +624,6 @@ void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota) {
void grpc_resource_quota_unref(grpc_resource_quota* resource_quota) {
ExecCtx _local_exec_ctx;
grpc_resource_quota_unref_internal(resource_quota);
- grpc_exec_ctx_finish();
}
grpc_resource_quota* grpc_resource_quota_ref_internal(
@@ -656,7 +655,6 @@ void grpc_resource_quota_resize(grpc_resource_quota* resource_quota,
(gpr_atm)GPR_MIN((size_t)GPR_ATM_MAX, size));
GRPC_CLOSURE_INIT(&a->closure, rq_resize, a, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_SCHED(&a->closure, GRPC_ERROR_NONE);
- grpc_exec_ctx_finish();
}
size_t grpc_resource_quota_peek_size(grpc_resource_quota* resource_quota) {
diff --git a/src/core/lib/iomgr/tcp_client_uv.cc b/src/core/lib/iomgr/tcp_client_uv.cc
index 2a127993a2..7454b01445 100644
--- a/src/core/lib/iomgr/tcp_client_uv.cc
+++ b/src/core/lib/iomgr/tcp_client_uv.cc
@@ -105,11 +105,10 @@ static void uv_tc_on_connect(uv_connect_t* req, int status) {
}
done = (--connect->refs == 0);
if (done) {
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
uv_tcp_connect_cleanup(connect);
}
GRPC_CLOSURE_SCHED(closure, error);
- grpc_exec_ctx_finish();
}
static void tcp_client_connect_impl(grpc_closure* closure, grpc_endpoint** ep,
diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc
index 697281d8b1..de3dabd7fc 100644
--- a/src/core/lib/iomgr/tcp_posix.cc
+++ b/src/core/lib/iomgr/tcp_posix.cc
@@ -130,7 +130,7 @@ static void run_poller(void* bp, grpc_error* error_ignored) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p);
}
gpr_mu_lock(p->pollset_mu);
- grpc_millis deadline = grpc_exec_ctx_now() + 13 * GPR_MS_PER_SEC;
+ grpc_millis deadline = ExecCtx::Get()->Now() + 13 * GPR_MS_PER_SEC;
GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS();
GRPC_LOG_IF_ERROR(
"backup_poller:pollset_work",
diff --git a/src/core/lib/iomgr/tcp_server_uv.cc b/src/core/lib/iomgr/tcp_server_uv.cc
index 8d5387fe6e..9db2cbe58d 100644
--- a/src/core/lib/iomgr/tcp_server_uv.cc
+++ b/src/core/lib/iomgr/tcp_server_uv.cc
@@ -142,7 +142,6 @@ static void handle_close_callback(uv_handle_t* handle) {
if (sp->server->open_ports == 0 && sp->server->shutdown) {
finish_shutdown(sp->server);
}
- grpc_exec_ctx_finish();
}
static void close_listener(grpc_tcp_listener* sp) {
@@ -177,14 +176,8 @@ void grpc_tcp_server_unref(grpc_tcp_server* s) {
/* Complete shutdown_starting work before destroying. */
ExecCtx _local_exec_ctx;
GRPC_CLOSURE_LIST_SCHED(&s->shutdown_starting);
- if (exec_ctx == NULL) {
- grpc_exec_ctx_flush();
- tcp_server_destroy(s);
- grpc_exec_ctx_finish();
- } else {
- grpc_exec_ctx_finish();
- tcp_server_destroy(s);
- }
+ ExecCtx::Get()->Flush();
+ tcp_server_destroy(s);
}
}
@@ -255,7 +248,6 @@ static void on_connect(uv_stream_t* server, int status) {
} else {
sp->has_pending_connection = true;
}
- grpc_exec_ctx_finish();
}
static grpc_error* add_socket_to_server(grpc_tcp_server* s, uv_tcp_t* handle,
diff --git a/src/core/lib/iomgr/tcp_uv.cc b/src/core/lib/iomgr/tcp_uv.cc
index 571c1d6f9a..3ea9674840 100644
--- a/src/core/lib/iomgr/tcp_uv.cc
+++ b/src/core/lib/iomgr/tcp_uv.cc
@@ -115,7 +115,6 @@ static void uv_close_callback(uv_handle_t* handle) {
ExecCtx _local_exec_ctx;
grpc_tcp* tcp = (grpc_tcp*)handle->data;
TCP_UNREF(tcp, "destroy");
- grpc_exec_ctx_finish();
}
static grpc_slice alloc_read_slice(grpc_resource_user* resource_user) {
@@ -130,7 +129,6 @@ static void alloc_uv_buf(uv_handle_t* handle, size_t suggested_size,
(void)suggested_size;
buf->base = (char*)GRPC_SLICE_START_PTR(tcp->read_slice);
buf->len = GRPC_SLICE_LENGTH(tcp->read_slice);
- grpc_exec_ctx_finish();
}
static void read_callback(uv_stream_t* stream, ssize_t nread,
@@ -174,7 +172,6 @@ static void read_callback(uv_stream_t* stream, ssize_t nread,
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed");
}
GRPC_CLOSURE_SCHED(cb, error);
- grpc_exec_ctx_finish();
}
static void uv_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
@@ -224,7 +221,6 @@ static void write_callback(uv_write_t* req, int status) {
grpc_resource_user_free(tcp->resource_user,
sizeof(uv_buf_t) * tcp->write_slices->count);
GRPC_CLOSURE_SCHED(cb, error);
- grpc_exec_ctx_finish();
}
static void uv_endpoint_write(grpc_endpoint* ep,
@@ -384,7 +380,6 @@ grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
uv_unref((uv_handle_t*)handle);
#endif
- grpc_exec_ctx_finish();
return &tcp->base;
}
diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc
index e7fe12b07b..d5e6066f35 100644
--- a/src/core/lib/iomgr/timer_generic.cc
+++ b/src/core/lib/iomgr/timer_generic.cc
@@ -249,7 +249,7 @@ void grpc_timer_list_init() {
g_shared_mutables.initialized = true;
g_shared_mutables.checker_mu = GPR_SPINLOCK_INITIALIZER;
gpr_mu_init(&g_shared_mutables.mu);
- g_shared_mutables.min_timer = grpc_exec_ctx_now();
+ g_shared_mutables.min_timer = ExecCtx::Get()->Now();
gpr_tls_init(&g_last_seen_min_timer);
gpr_tls_set(&g_last_seen_min_timer, 0);
grpc_register_tracer(&grpc_timer_trace);
@@ -341,7 +341,7 @@ void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
if (GRPC_TRACER_ON(grpc_timer_trace)) {
gpr_log(GPR_DEBUG,
"TIMER %p: SET %" PRIdPTR " now %" PRIdPTR " call %p[%p]", timer,
- deadline, grpc_exec_ctx_now(), closure, closure->cb);
+ deadline, ExecCtx::Get()->Now(), closure, closure->cb);
}
if (!g_shared_mutables.initialized) {
@@ -354,7 +354,7 @@ void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
gpr_mu_lock(&shard->mu);
timer->pending = true;
- grpc_millis now = grpc_exec_ctx_now();
+ grpc_millis now = ExecCtx::Get()->Now();
if (deadline <= now) {
timer->pending = false;
GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
@@ -607,7 +607,7 @@ static grpc_timer_check_result run_some_expired_timers(gpr_atm now,
grpc_timer_check_result grpc_timer_check(grpc_millis* next) {
// prelude
- grpc_millis now = grpc_exec_ctx_now();
+ grpc_millis now = ExecCtx::Get()->Now();
/* fetch from a thread-local first: this avoids contention on a globally
mutable cacheline in the common case */
diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc
index 499fc73748..69adb673d8 100644
--- a/src/core/lib/iomgr/timer_manager.cc
+++ b/src/core/lib/iomgr/timer_manager.cc
@@ -101,7 +101,6 @@ void grpc_timer_manager_tick() {
ExecCtx _local_exec_ctx;
grpc_millis next = GRPC_MILLIS_INF_FUTURE;
grpc_timer_check(&next);
- grpc_exec_ctx_finish();
}
static void run_some_timers() {
@@ -126,7 +125,7 @@ static void run_some_timers() {
if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
gpr_log(GPR_DEBUG, "flush exec_ctx");
}
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&g_mu);
// garbage collect any threads hanging out that are dead
gc_completed_threads();
@@ -179,7 +178,7 @@ static bool wait_until(grpc_millis next) {
g_timed_waiter_deadline = next;
if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
- grpc_millis wait_time = next - grpc_exec_ctx_now();
+ grpc_millis wait_time = next - ExecCtx::Get()->Now();
gpr_log(GPR_DEBUG, "sleep for a %" PRIdPTR " milliseconds",
wait_time);
}
@@ -224,7 +223,7 @@ static bool wait_until(grpc_millis next) {
static void timer_main_loop() {
for (;;) {
grpc_millis next = GRPC_MILLIS_INF_FUTURE;
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
// check timer state, updates next to the next time to run a check
switch (grpc_timer_check(&next)) {
case GRPC_TIMERS_FIRED:
@@ -274,9 +273,9 @@ static void timer_thread_cleanup(completed_thread* ct) {
static void timer_thread(void* completed_thread_ptr) {
// this threads exec_ctx: we try to run things through to completion here
// since it's easy to spin up new threads
- ExecCtx _local_exec_ctx(0, grpc_never_ready_to_finish, NULL);
+ ExecCtx _local_exec_ctx;
timer_main_loop();
- grpc_exec_ctx_finish();
+
timer_thread_cleanup((completed_thread*)completed_thread_ptr);
}
diff --git a/src/core/lib/iomgr/timer_uv.cc b/src/core/lib/iomgr/timer_uv.cc
index 94601d99af..6edd4169f1 100644
--- a/src/core/lib/iomgr/timer_uv.cc
+++ b/src/core/lib/iomgr/timer_uv.cc
@@ -51,7 +51,6 @@ void run_expired_timer(uv_timer_t* handle) {
timer->pending = 0;
GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
stop_uv_timer(handle);
- grpc_exec_ctx_finish();
}
void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
@@ -60,13 +59,13 @@ void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
uv_timer_t* uv_timer;
GRPC_UV_ASSERT_SAME_THREAD();
timer->closure = closure;
- if (deadline <= grpc_exec_ctx_now()) {
+ if (deadline <= ExecCtx::Get()->Now()) {
timer->pending = 0;
GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
return;
}
timer->pending = 1;
- timeout = (uint64_t)(deadline - grpc_exec_ctx_now());
+ timeout = (uint64_t)(deadline - ExecCtx::Get()->Now());
uv_timer = (uv_timer_t*)gpr_malloc(sizeof(uv_timer_t));
uv_timer_init(uv_default_loop(), uv_timer);
uv_timer->data = timer;
diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc
index 1d708c997c..9b58b3657f 100644
--- a/src/core/lib/security/context/security_context.cc
+++ b/src/core/lib/security/context/security_context.cc
@@ -57,7 +57,7 @@ grpc_call_error grpc_call_set_credentials(grpc_call* call,
grpc_call_credentials_unref(ctx->creds);
ctx->creds = grpc_call_credentials_ref(creds);
}
- grpc_exec_ctx_finish();
+
return GRPC_CALL_OK;
}
@@ -95,7 +95,6 @@ void grpc_client_security_context_destroy(void* ctx) {
c->extension.destroy(c->extension.instance);
}
gpr_free(ctx);
- grpc_exec_ctx_finish();
}
/* --- grpc_server_security_context --- */
diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc
index 20c4ae70fb..6a272653f8 100644
--- a/src/core/lib/security/credentials/credentials.cc
+++ b/src/core/lib/security/credentials/credentials.cc
@@ -74,7 +74,6 @@ void grpc_channel_credentials_release(grpc_channel_credentials* creds) {
GRPC_API_TRACE("grpc_channel_credentials_release(creds=%p)", 1, (creds));
ExecCtx _local_exec_ctx;
grpc_channel_credentials_unref(creds);
- grpc_exec_ctx_finish();
}
grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds) {
@@ -97,7 +96,6 @@ void grpc_call_credentials_release(grpc_call_credentials* creds) {
GRPC_API_TRACE("grpc_call_credentials_release(creds=%p)", 1, (creds));
ExecCtx _local_exec_ctx;
grpc_call_credentials_unref(creds);
- grpc_exec_ctx_finish();
}
bool grpc_call_credentials_get_request_metadata(
@@ -213,7 +211,6 @@ void grpc_server_credentials_release(grpc_server_credentials* creds) {
GRPC_API_TRACE("grpc_server_credentials_release(creds=%p)", 1, (creds));
ExecCtx _local_exec_ctx;
grpc_server_credentials_unref(creds);
- grpc_exec_ctx_finish();
}
grpc_security_status grpc_server_credentials_create_security_connector(
diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
index 897b9d7520..03ec4bc3b3 100644
--- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc
+++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
@@ -114,13 +114,13 @@ static int is_stack_running_on_compute_engine() {
grpc_resource_quota_create("google_default_credentials");
grpc_httpcli_get(
&context, &detector.pollent, resource_quota, &request,
- grpc_exec_ctx_now() + max_detection_delay,
+ ExecCtx::Get()->Now() + max_detection_delay,
GRPC_CLOSURE_CREATE(on_compute_engine_detection_http_response, &detector,
grpc_schedule_on_exec_ctx),
&detector.response);
grpc_resource_quota_unref_internal(resource_quota);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Block until we get the response. This is not ideal but this should only be
called once for the lifetime of the process by the default credentials. */
@@ -144,7 +144,7 @@ static int is_stack_running_on_compute_engine() {
grpc_pollset_shutdown(grpc_polling_entity_pollset(&detector.pollent),
&destroy_closure);
g_polling_mu = NULL;
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_free(grpc_polling_entity_pollset(&detector.pollent));
grpc_http_response_destroy(&detector.response);
@@ -285,7 +285,7 @@ end:
} else {
GRPC_ERROR_UNREF(error);
}
- grpc_exec_ctx_finish();
+
return result;
}
@@ -299,7 +299,6 @@ void grpc_flush_cached_google_default_credentials(void) {
}
compute_engine_detection_done = 0;
gpr_mu_unlock(&g_state_mu);
- grpc_exec_ctx_finish();
}
/* -- Well known credentials path. -- */
diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc
index 07938ec67e..4d9da0cbe3 100644
--- a/src/core/lib/security/credentials/iam/iam_credentials.cc
+++ b/src/core/lib/security/credentials/iam/iam_credentials.cc
@@ -77,6 +77,6 @@ grpc_call_credentials* grpc_google_iam_credentials_create(
grpc_slice_from_copied_string(authority_selector));
grpc_credentials_mdelem_array_add(&c->md_array, md);
GRPC_MDELEM_UNREF(md);
- grpc_exec_ctx_finish();
+
return &c->base;
}
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
index 1d43ee6e03..ccc3f4aeed 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
@@ -185,6 +185,6 @@ grpc_call_credentials* grpc_service_account_jwt_access_credentials_create(
grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
grpc_auth_json_key_create_from_string(json_key), token_lifetime);
- grpc_exec_ctx_finish();
+
return creds;
}
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
index eaa2078787..5246e1f985 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.cc
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
@@ -358,7 +358,7 @@ static verifier_cb_ctx* verifier_cb_ctx_create(
ctx->signed_data = grpc_slice_from_copied_buffer(signed_jwt, signed_jwt_len);
ctx->user_data = user_data;
ctx->user_cb = cb;
- grpc_exec_ctx_finish();
+
return ctx;
}
@@ -702,7 +702,7 @@ static void on_openid_config_retrieved(void* user_data, grpc_error* error) {
resource_quota = grpc_resource_quota_create("jwt_verifier");
grpc_httpcli_get(
&ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
- grpc_exec_ctx_now() + grpc_jwt_verifier_max_delay,
+ ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay,
GRPC_CLOSURE_CREATE(on_keys_retrieved, ctx, grpc_schedule_on_exec_ctx),
&ctx->responses[HTTP_RESPONSE_KEYS]);
grpc_resource_quota_unref_internal(resource_quota);
@@ -828,7 +828,7 @@ static void retrieve_key_and_verify(verifier_cb_ctx* ctx) {
extreme memory pressure. */
resource_quota = grpc_resource_quota_create("jwt_verifier");
grpc_httpcli_get(&ctx->verifier->http_ctx, &ctx->pollent, resource_quota,
- &req, grpc_exec_ctx_now() + grpc_jwt_verifier_max_delay,
+ &req, ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay,
http_cb, &ctx->responses[rsp_idx]);
grpc_resource_quota_unref_internal(resource_quota);
gpr_free(req.host);
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
index bae9692938..b653705609 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
@@ -216,8 +216,9 @@ static void on_oauth2_token_fetcher_http_response(void* user_data,
gpr_mu_lock(&c->mu);
c->token_fetch_pending = false;
c->access_token_md = GRPC_MDELEM_REF(access_token_md);
- c->token_expiration =
- status == GRPC_CREDENTIALS_OK ? grpc_exec_ctx_now() + token_lifetime : 0;
+ c->token_expiration = status == GRPC_CREDENTIALS_OK
+ ? ExecCtx::Get()->Now() + token_lifetime
+ : 0;
grpc_oauth2_pending_get_request_metadata* pending_request =
c->pending_requests;
c->pending_requests = NULL;
@@ -255,7 +256,7 @@ static bool oauth2_token_fetcher_get_request_metadata(
grpc_mdelem cached_access_token_md = GRPC_MDNULL;
gpr_mu_lock(&c->mu);
if (!GRPC_MDISNULL(c->access_token_md) &&
- (c->token_expiration - grpc_exec_ctx_now() > refresh_threshold)) {
+ (c->token_expiration - ExecCtx::Get()->Now() > refresh_threshold)) {
cached_access_token_md = GRPC_MDELEM_REF(c->access_token_md);
}
if (!GRPC_MDISNULL(cached_access_token_md)) {
@@ -287,7 +288,7 @@ static bool oauth2_token_fetcher_get_request_metadata(
c->fetch_func(grpc_credentials_metadata_request_create(creds),
&c->httpcli_context, &c->pollent,
on_oauth2_token_fetcher_http_response,
- grpc_exec_ctx_now() + refresh_threshold);
+ ExecCtx::Get()->Now() + refresh_threshold);
}
return false;
}
@@ -517,7 +518,7 @@ grpc_call_credentials* grpc_access_token_credentials_create(
c->access_token_md = grpc_mdelem_from_slices(
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(token_md_value));
- grpc_exec_ctx_finish();
+
gpr_free(token_md_value);
return &c->base;
}
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
index 064666a7d0..025d024617 100644
--- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc
+++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
@@ -116,9 +116,8 @@ static void plugin_md_request_metadata_ready(void* request,
grpc_status_code status,
const char* error_details) {
/* called from application code */
- ExecCtx _local_exec_ctx(
- GRPC_EXEC_CTX_FLAG_IS_FINISHED | GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP,
- NULL, NULL);
+ ExecCtx _local_exec_ctx(GRPC_EXEC_CTX_FLAG_IS_FINISHED |
+ GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP);
grpc_plugin_credentials_pending_request* r =
(grpc_plugin_credentials_pending_request*)request;
if (GRPC_TRACER_ON(grpc_plugin_credentials_trace)) {
@@ -141,7 +140,6 @@ static void plugin_md_request_metadata_ready(void* request,
r->creds, r);
}
gpr_free(r);
- grpc_exec_ctx_finish();
}
static bool plugin_get_request_metadata(grpc_call_credentials* creds,
diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc
index cb20401409..4ed2ec55bd 100644
--- a/src/core/lib/security/transport/security_handshaker.cc
+++ b/src/core/lib/security/transport/security_handshaker.cc
@@ -266,7 +266,6 @@ static void on_handshake_next_done_grpc_wrapper(
} else {
gpr_mu_unlock(&h->mu);
}
- grpc_exec_ctx_finish();
}
static grpc_error* do_handshaker_next_locked(
diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc
index 5f21a2933b..86817076f8 100644
--- a/src/core/lib/security/transport/server_auth_filter.cc
+++ b/src/core/lib/security/transport/server_auth_filter.cc
@@ -141,7 +141,6 @@ static void on_md_processing_done(
}
grpc_metadata_array_destroy(&calld->md);
GRPC_CALL_STACK_UNREF(calld->owning_call, "server_auth_metadata");
- grpc_exec_ctx_finish();
}
static void cancel_call(void* arg, grpc_error* error) {
diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc
index 3b3b2e4f05..6e1554d471 100644
--- a/src/core/lib/slice/slice.cc
+++ b/src/core/lib/slice/slice.cc
@@ -69,7 +69,6 @@ grpc_slice grpc_slice_ref(grpc_slice slice) {
void grpc_slice_unref(grpc_slice slice) {
ExecCtx _local_exec_ctx;
grpc_slice_unref_internal(slice);
- grpc_exec_ctx_finish();
}
/* grpc_slice_from_static_string support structure - a refcount that does
diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc
index 6774269972..4bc54c303f 100644
--- a/src/core/lib/slice/slice_buffer.cc
+++ b/src/core/lib/slice/slice_buffer.cc
@@ -75,7 +75,6 @@ void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb) {
void grpc_slice_buffer_destroy(grpc_slice_buffer* sb) {
ExecCtx _local_exec_ctx;
grpc_slice_buffer_destroy_internal(sb);
- grpc_exec_ctx_finish();
}
uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) {
@@ -175,7 +174,6 @@ void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb) {
void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb) {
ExecCtx _local_exec_ctx;
grpc_slice_buffer_reset_and_unref_internal(sb);
- grpc_exec_ctx_finish();
}
void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b) {
diff --git a/src/core/lib/surface/alarm.cc b/src/core/lib/surface/alarm.cc
index 395ffd393c..7aee100f3f 100644
--- a/src/core/lib/surface/alarm.cc
+++ b/src/core/lib/surface/alarm.cc
@@ -51,7 +51,7 @@ static void alarm_unref(grpc_alarm* alarm) {
if (alarm->cq != NULL) {
GRPC_CQ_INTERNAL_UNREF(alarm->cq, "alarm");
}
- grpc_exec_ctx_finish();
+
gpr_free(alarm);
}
}
@@ -126,13 +126,11 @@ void grpc_alarm_set(grpc_alarm* alarm, grpc_completion_queue* cq,
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
grpc_timer_init(&alarm->alarm, grpc_timespec_to_millis_round_up(deadline),
&alarm->on_alarm);
- grpc_exec_ctx_finish();
}
void grpc_alarm_cancel(grpc_alarm* alarm, void* reserved) {
ExecCtx _local_exec_ctx;
grpc_timer_cancel(&alarm->alarm);
- grpc_exec_ctx_finish();
}
void grpc_alarm_destroy(grpc_alarm* alarm, void* reserved) {
diff --git a/src/core/lib/surface/byte_buffer.cc b/src/core/lib/surface/byte_buffer.cc
index f3c10797f3..6a9b13bb41 100644
--- a/src/core/lib/surface/byte_buffer.cc
+++ b/src/core/lib/surface/byte_buffer.cc
@@ -78,7 +78,6 @@ void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) {
break;
}
gpr_free(bb);
- grpc_exec_ctx_finish();
}
size_t grpc_byte_buffer_length(grpc_byte_buffer* bb) {
diff --git a/src/core/lib/surface/byte_buffer_reader.cc b/src/core/lib/surface/byte_buffer_reader.cc
index fb66829baa..9a9e26ecdc 100644
--- a/src/core/lib/surface/byte_buffer_reader.cc
+++ b/src/core/lib/surface/byte_buffer_reader.cc
@@ -70,7 +70,7 @@ int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
reader->current.index = 0;
break;
}
- grpc_exec_ctx_finish();
+
return 1;
}
@@ -118,6 +118,6 @@ grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader) {
grpc_slice_unref_internal(in_slice);
GPR_ASSERT(bytes_read <= input_size);
}
- grpc_exec_ctx_finish();
+
return out_slice;
}
diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc
index 5e1c0badd0..bbb7a39e29 100644
--- a/src/core/lib/surface/call.cc
+++ b/src/core/lib/surface/call.cc
@@ -595,7 +595,7 @@ void grpc_call_unref(grpc_call* c) {
grpc_call_combiner_set_notify_on_cancel(&c->call_combiner, NULL);
}
GRPC_CALL_INTERNAL_UNREF(c, "destroy");
- grpc_exec_ctx_finish();
+
GPR_TIMER_END("grpc_call_unref", 0);
}
@@ -604,7 +604,7 @@ grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
GPR_ASSERT(!reserved);
ExecCtx _local_exec_ctx;
cancel_with_error(call, STATUS_FROM_API_OVERRIDE, GRPC_ERROR_CANCELLED);
- grpc_exec_ctx_finish();
+
return GRPC_CALL_OK;
}
@@ -659,7 +659,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
4, (c, (int)status, description, reserved));
GPR_ASSERT(reserved == NULL);
cancel_with_status(c, STATUS_FROM_API_OVERRIDE, status, description);
- grpc_exec_ctx_finish();
+
return GRPC_CALL_OK;
}
@@ -2048,7 +2048,6 @@ grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
err = call_start_batch(call, ops, nops, tag, 0);
}
- grpc_exec_ctx_finish();
return err;
}
diff --git a/src/core/lib/surface/call_details.cc b/src/core/lib/surface/call_details.cc
index 01b19abefb..03ce7f88fb 100644
--- a/src/core/lib/surface/call_details.cc
+++ b/src/core/lib/surface/call_details.cc
@@ -37,5 +37,4 @@ void grpc_call_details_destroy(grpc_call_details* cd) {
ExecCtx _local_exec_ctx;
grpc_slice_unref_internal(cd->method);
grpc_slice_unref_internal(cd->host);
- grpc_exec_ctx_finish();
}
diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc
index dc1fc1632e..7725351f74 100644
--- a/src/core/lib/surface/channel.cc
+++ b/src/core/lib/surface/channel.cc
@@ -252,7 +252,6 @@ void grpc_channel_get_info(grpc_channel* channel,
grpc_channel_element* elem =
grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0);
elem->filter->get_channel_info(elem, channel_info);
- grpc_exec_ctx_finish();
}
static grpc_call* grpc_channel_create_call_internal(
@@ -305,7 +304,7 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel,
grpc_slice_ref_internal(*host))
: GRPC_MDNULL,
grpc_timespec_to_millis_round_up(deadline));
- grpc_exec_ctx_finish();
+
return call;
}
@@ -344,7 +343,7 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method,
rc->next = channel->registered_calls;
channel->registered_calls = rc;
gpr_mu_unlock(&channel->registered_call_mu);
- grpc_exec_ctx_finish();
+
return rc;
}
@@ -370,7 +369,7 @@ grpc_call* grpc_channel_create_registered_call(
channel, parent_call, propagation_mask, completion_queue, NULL,
GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority),
grpc_timespec_to_millis_round_up(deadline));
- grpc_exec_ctx_finish();
+
return call;
}
@@ -416,8 +415,6 @@ void grpc_channel_destroy(grpc_channel* channel) {
elem->filter->start_transport_op(elem, op);
GRPC_CHANNEL_INTERNAL_UNREF(channel, "channel");
-
- grpc_exec_ctx_finish();
}
grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel) {
diff --git a/src/core/lib/surface/channel_ping.cc b/src/core/lib/surface/channel_ping.cc
index 0966a8d967..06cdbf6c73 100644
--- a/src/core/lib/surface/channel_ping.cc
+++ b/src/core/lib/surface/channel_ping.cc
@@ -60,5 +60,4 @@ void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
op->bind_pollset = grpc_cq_pollset(cq);
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
top_elem->filter->start_transport_op(top_elem, op);
- grpc_exec_ctx_finish();
}
diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc
index b69d40534d..0b0a8d070d 100644
--- a/src/core/lib/surface/completion_queue.cc
+++ b/src/core/lib/surface/completion_queue.cc
@@ -124,7 +124,7 @@ static grpc_error* non_polling_poller_work(grpc_pollset* pollset,
while (!npp->shutdown && !w.kicked &&
!gpr_cv_wait(&w.cv, &npp->mu, deadline_ts))
;
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
if (&w == npp->root) {
npp->root = w.next;
if (&w == npp->root) {
@@ -371,7 +371,6 @@ int grpc_completion_queue_thread_local_cache_flush(grpc_completion_queue* cq,
gpr_mu_unlock(cq->mu);
GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
}
- grpc_exec_ctx_finish();
}
gpr_tls_set(&g_cached_event, (intptr_t)0);
gpr_tls_set(&g_cached_cq, (intptr_t)0);
@@ -412,8 +411,6 @@ static grpc_cq_completion* cq_event_queue_pop(grpc_cq_event_queue* q) {
GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_FAILURES();
}
- grpc_exec_ctx_finish();
-
if (c) {
gpr_atm_no_barrier_fetch_add(&q->num_queue_items, -1);
}
@@ -445,7 +442,6 @@ grpc_completion_queue* grpc_completion_queue_create_internal(
ExecCtx _local_exec_ctx;
GRPC_STATS_INC_CQS_CREATED();
- grpc_exec_ctx_finish();
cq = (grpc_completion_queue*)gpr_zalloc(sizeof(grpc_completion_queue) +
vtable->data_size +
@@ -639,9 +635,9 @@ static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag,
error != GRPC_ERROR_NONE)) {
const char* errmsg = grpc_error_string(error);
GRPC_API_TRACE(
- "cq_end_op_for_next(=%p, cq=%p, tag=%p, error=%s, "
+ "cq_end_op_for_next(cq=%p, tag=%p, error=%s, "
"done=%p, done_arg=%p, storage=%p)",
- 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
+ 6, (cq, tag, errmsg, done, done_arg, storage));
if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
@@ -726,9 +722,9 @@ static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag,
error != GRPC_ERROR_NONE)) {
const char* errmsg = grpc_error_string(error);
GRPC_API_TRACE(
- "cq_end_op_for_pluck(=%p, cq=%p, tag=%p, error=%s, "
+ "cq_end_op_for_pluck(cq=%p, tag=%p, error=%s, "
"done=%p, done_arg=%p, storage=%p)",
- 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
+ 6, (cq, tag, errmsg, done, done_arg, storage));
if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
@@ -794,31 +790,40 @@ typedef struct {
bool first_loop;
} cq_is_finished_arg;
-static bool cq_is_next_finished(void* arg) {
- cq_is_finished_arg* a = (cq_is_finished_arg*)arg;
- grpc_completion_queue* cq = a->cq;
- cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
- GPR_ASSERT(a->stolen_completion == NULL);
+class ExecCtxNext : public ExecCtx {
+ public:
+ ExecCtxNext(void* arg) : ExecCtx(0), check_ready_to_finish_arg_(arg) {}
- gpr_atm current_last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+ bool CheckReadyToFinish() override {
+ cq_is_finished_arg* a = (cq_is_finished_arg*)check_ready_to_finish_arg_;
+ grpc_completion_queue* cq = a->cq;
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+ GPR_ASSERT(a->stolen_completion == NULL);
- if (current_last_seen_things_queued_ever != a->last_seen_things_queued_ever) {
- a->last_seen_things_queued_ever =
+ gpr_atm current_last_seen_things_queued_ever =
gpr_atm_no_barrier_load(&cqd->things_queued_ever);
- /* Pop a cq_completion from the queue. Returns NULL if the queue is empty
- * might return NULL in some cases even if the queue is not empty; but
- * that
- * is ok and doesn't affect correctness. Might effect the tail latencies a
- * bit) */
- a->stolen_completion = cq_event_queue_pop(&cqd->queue);
- if (a->stolen_completion != NULL) {
- return true;
+ if (current_last_seen_things_queued_ever !=
+ a->last_seen_things_queued_ever) {
+ a->last_seen_things_queued_ever =
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+
+ /* Pop a cq_completion from the queue. Returns NULL if the queue is empty
+ * might return NULL in some cases even if the queue is not empty; but
+ * that
+ * is ok and doesn't affect correctness. Might effect the tail latencies a
+ * bit) */
+ a->stolen_completion = cq_event_queue_pop(&cqd->queue);
+ if (a->stolen_completion != NULL) {
+ return true;
+ }
}
+ return !a->first_loop && a->deadline < ExecCtx::Get()->Now();
}
- return !a->first_loop && a->deadline < grpc_exec_ctx_now();
-}
+
+ private:
+ void* check_ready_to_finish_arg_;
+};
#ifndef NDEBUG
static void dump_pending_tags(grpc_completion_queue* cq) {
@@ -873,7 +878,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
NULL,
NULL,
true};
- ExecCtx _local_exec_ctx(0, cq_is_next_finished, &is_finished_arg);
+ ExecCtxNext _local_exec_ctx(&is_finished_arg);
for (;;) {
grpc_millis iteration_deadline = deadline_millis;
@@ -923,7 +928,8 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
break;
}
- if (!is_finished_arg.first_loop && grpc_exec_ctx_now() >= deadline_millis) {
+ if (!is_finished_arg.first_loop &&
+ ExecCtx::Get()->Now() >= deadline_millis) {
memset(&ret, 0, sizeof(ret));
ret.type = GRPC_QUEUE_TIMEOUT;
dump_pending_tags(cq);
@@ -959,7 +965,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
GRPC_CQ_INTERNAL_UNREF(cq, "next");
- grpc_exec_ctx_finish();
+
GPR_ASSERT(is_finished_arg.stolen_completion == NULL);
GPR_TIMER_END("grpc_completion_queue_next", 0);
@@ -1039,37 +1045,46 @@ static void del_plucker(grpc_completion_queue* cq, void* tag,
GPR_UNREACHABLE_CODE(return );
}
-static bool cq_is_pluck_finished(void* arg) {
- cq_is_finished_arg* a = (cq_is_finished_arg*)arg;
- grpc_completion_queue* cq = a->cq;
- cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+class ExecCtxPluck : public ExecCtx {
+ public:
+ ExecCtxPluck(void* arg) : ExecCtx(0), check_ready_to_finish_arg_(arg) {}
- GPR_ASSERT(a->stolen_completion == NULL);
- gpr_atm current_last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever);
- if (current_last_seen_things_queued_ever != a->last_seen_things_queued_ever) {
- gpr_mu_lock(cq->mu);
- a->last_seen_things_queued_ever =
+ bool CheckReadyToFinish() override {
+ cq_is_finished_arg* a = (cq_is_finished_arg*)check_ready_to_finish_arg_;
+ grpc_completion_queue* cq = a->cq;
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+
+ GPR_ASSERT(a->stolen_completion == NULL);
+ gpr_atm current_last_seen_things_queued_ever =
gpr_atm_no_barrier_load(&cqd->things_queued_ever);
- grpc_cq_completion* c;
- grpc_cq_completion* prev = &cqd->completed_head;
- while ((c = (grpc_cq_completion*)(prev->next & ~(uintptr_t)1)) !=
- &cqd->completed_head) {
- if (c->tag == a->tag) {
- prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
- if (c == cqd->completed_tail) {
- cqd->completed_tail = prev;
+ if (current_last_seen_things_queued_ever !=
+ a->last_seen_things_queued_ever) {
+ gpr_mu_lock(cq->mu);
+ a->last_seen_things_queued_ever =
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+ grpc_cq_completion* c;
+ grpc_cq_completion* prev = &cqd->completed_head;
+ while ((c = (grpc_cq_completion*)(prev->next & ~(uintptr_t)1)) !=
+ &cqd->completed_head) {
+ if (c->tag == a->tag) {
+ prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
+ if (c == cqd->completed_tail) {
+ cqd->completed_tail = prev;
+ }
+ gpr_mu_unlock(cq->mu);
+ a->stolen_completion = c;
+ return true;
}
- gpr_mu_unlock(cq->mu);
- a->stolen_completion = c;
- return true;
+ prev = c;
}
- prev = c;
+ gpr_mu_unlock(cq->mu);
}
- gpr_mu_unlock(cq->mu);
+ return !a->first_loop && a->deadline < ExecCtx::Get()->Now();
}
- return !a->first_loop && a->deadline < grpc_exec_ctx_now();
-}
+
+ private:
+ void* check_ready_to_finish_arg_;
+};
static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
gpr_timespec deadline, void* reserved) {
@@ -1106,7 +1121,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
NULL,
tag,
true};
- ExecCtx _local_exec_ctx(0, cq_is_pluck_finished, &is_finished_arg);
+ ExecCtxPluck _local_exec_ctx(&is_finished_arg);
for (;;) {
if (is_finished_arg.stolen_completion != NULL) {
gpr_mu_unlock(cq->mu);
@@ -1153,7 +1168,8 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
dump_pending_tags(cq);
break;
}
- if (!is_finished_arg.first_loop && grpc_exec_ctx_now() >= deadline_millis) {
+ if (!is_finished_arg.first_loop &&
+ ExecCtx::Get()->Now() >= deadline_millis) {
del_plucker(cq, tag, &worker);
gpr_mu_unlock(cq->mu);
memset(&ret, 0, sizeof(ret));
@@ -1182,7 +1198,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
done:
GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
GRPC_CQ_INTERNAL_UNREF(cq, "pluck");
- grpc_exec_ctx_finish();
+
GPR_ASSERT(is_finished_arg.stolen_completion == NULL);
GPR_TIMER_END("grpc_completion_queue_pluck", 0);
@@ -1238,7 +1254,7 @@ void grpc_completion_queue_shutdown(grpc_completion_queue* cq) {
GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0);
GRPC_API_TRACE("grpc_completion_queue_shutdown(cq=%p)", 1, (cq));
cq->vtable->shutdown(cq);
- grpc_exec_ctx_finish();
+
GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
}
@@ -1249,7 +1265,7 @@ void grpc_completion_queue_destroy(grpc_completion_queue* cq) {
ExecCtx _local_exec_ctx;
GRPC_CQ_INTERNAL_UNREF(cq, "destroy");
- grpc_exec_ctx_finish();
+
GPR_TIMER_END("grpc_completion_queue_destroy", 0);
}
diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc
index 66c8c3b6da..20e17a7f60 100644
--- a/src/core/lib/surface/init.cc
+++ b/src/core/lib/surface/init.cc
@@ -168,14 +168,14 @@ void grpc_init(void) {
grpc_iomgr_start();
}
gpr_mu_unlock(&g_init_mu);
- grpc_exec_ctx_finish();
+
GRPC_API_TRACE("grpc_init(void)", 0, ());
}
void grpc_shutdown(void) {
int i;
GRPC_API_TRACE("grpc_shutdown(void)", 0, ());
- ExecCtx _local_exec_ctx(0, grpc_never_ready_to_finish, NULL);
+ ExecCtx _local_exec_ctx;
gpr_mu_lock(&g_init_mu);
if (--g_initializations == 0) {
grpc_executor_shutdown();
@@ -194,7 +194,6 @@ void grpc_shutdown(void) {
grpc_stats_shutdown();
}
gpr_mu_unlock(&g_init_mu);
- grpc_exec_ctx_finish();
}
int grpc_is_initialized(void) {
diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc
index 5cd8c1fd89..da081e68cb 100644
--- a/src/core/lib/surface/lame_client.cc
+++ b/src/core/lib/surface/lame_client.cc
@@ -169,6 +169,6 @@ grpc_channel* grpc_lame_client_channel_create(const char* target,
auto chand = reinterpret_cast<grpc_core::ChannelData*>(elem->channel_data);
chand->error_code = error_code;
chand->error_message = error_message;
- grpc_exec_ctx_finish();
+
return channel;
}
diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc
index 6e3ce005a2..0d4435d556 100644
--- a/src/core/lib/surface/server.cc
+++ b/src/core/lib/surface/server.cc
@@ -1047,8 +1047,6 @@ void grpc_server_start(grpc_server* server) {
GRPC_CLOSURE_CREATE(start_listeners, server,
grpc_executor_scheduler(GRPC_EXECUTOR_SHORT)),
GRPC_ERROR_NONE);
-
- grpc_exec_ctx_finish();
}
void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
@@ -1188,7 +1186,7 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
grpc_cq_end_op(cq, tag, GRPC_ERROR_NONE, done_published_shutdown, NULL,
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
gpr_mu_unlock(&server->mu_global);
- goto done;
+ return;
}
server->shutdown_tags = (shutdown_tag*)gpr_realloc(
server->shutdown_tags,
@@ -1198,7 +1196,7 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
sdt->cq = cq;
if (gpr_atm_acq_load(&server->shutdown_flag)) {
gpr_mu_unlock(&server->mu_global);
- goto done;
+ return;
}
server->last_shutdown_message_time = gpr_now(GPR_CLOCK_REALTIME);
@@ -1225,9 +1223,6 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
channel_broadcaster_shutdown(&broadcaster, true /* send_goaway */,
GRPC_ERROR_NONE);
-
-done:
- grpc_exec_ctx_finish();
}
void grpc_server_cancel_all_calls(grpc_server* server) {
@@ -1243,7 +1238,6 @@ void grpc_server_cancel_all_calls(grpc_server* server) {
channel_broadcaster_shutdown(
&broadcaster, false /* send_goaway */,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Cancelling all calls"));
- grpc_exec_ctx_finish();
}
void grpc_server_destroy(grpc_server* server) {
@@ -1265,7 +1259,6 @@ void grpc_server_destroy(grpc_server* server) {
gpr_mu_unlock(&server->mu_global);
server_unref(server);
- grpc_exec_ctx_finish();
}
void grpc_server_add_listener(grpc_server* server, void* arg,
@@ -1368,7 +1361,7 @@ grpc_call_error grpc_server_request_call(
rc->initial_metadata = initial_metadata;
error = queue_call_request(server, cq_idx, rc);
done:
- grpc_exec_ctx_finish();
+
return error;
}
@@ -1425,7 +1418,7 @@ grpc_call_error grpc_server_request_registered_call(
rc->data.registered.optional_payload = optional_payload;
error = queue_call_request(server, cq_idx, rc);
done:
- grpc_exec_ctx_finish();
+
return error;
}
diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc
index 47d65870d1..4e279b4d94 100644
--- a/src/core/lib/transport/bdp_estimator.cc
+++ b/src/core/lib/transport/bdp_estimator.cc
@@ -79,7 +79,7 @@ grpc_millis BdpEstimator::CompletePing() {
}
ping_state_ = PingState::UNSCHEDULED;
accumulator_ = 0;
- return grpc_exec_ctx_now() + inter_ping_delay_;
+ return ExecCtx::Get()->Now() + inter_ping_delay_;
}
} // namespace grpc_core
diff --git a/src/core/lib/transport/status_conversion.cc b/src/core/lib/transport/status_conversion.cc
index fd7764f2db..61470b8c78 100644
--- a/src/core/lib/transport/status_conversion.cc
+++ b/src/core/lib/transport/status_conversion.cc
@@ -46,8 +46,8 @@ grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error,
case GRPC_HTTP2_CANCEL:
/* http2 cancel translates to STATUS_CANCELLED iff deadline hasn't been
* exceeded */
- return grpc_exec_ctx_now() > deadline ? GRPC_STATUS_DEADLINE_EXCEEDED
- : GRPC_STATUS_CANCELLED;
+ return ExecCtx::Get()->Now() > deadline ? GRPC_STATUS_DEADLINE_EXCEEDED
+ : GRPC_STATUS_CANCELLED;
case GRPC_HTTP2_ENHANCE_YOUR_CALM:
return GRPC_STATUS_RESOURCE_EXHAUSTED;
case GRPC_HTTP2_INADEQUATE_SECURITY:
diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc
index 6f31bd07f9..ca80a7404d 100644
--- a/src/core/lib/transport/transport.cc
+++ b/src/core/lib/transport/transport.cc
@@ -62,7 +62,7 @@ void grpc_stream_unref(grpc_stream_refcount* refcount, const char* reason) {
void grpc_stream_unref(grpc_stream_refcount* refcount) {
#endif
if (gpr_unref(&refcount->refs)) {
- if (exec_ctx->flags & GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP) {
+ if (ExecCtx::Get()->flags() & GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP) {
/* Ick.
The thread we're running on MAY be owned (indirectly) by a call-stack.
If that's the case, destroying the call-stack MAY try to destroy the
diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc
index 79e4aee4e2..0bcfac2845 100644
--- a/src/cpp/common/channel_arguments.cc
+++ b/src/cpp/common/channel_arguments.cc
@@ -73,7 +73,6 @@ ChannelArguments::~ChannelArguments() {
it->value.pointer.vtable->destroy(it->value.pointer.p);
}
}
- grpc_exec_ctx_finish();
}
void ChannelArguments::Swap(ChannelArguments& other) {
@@ -106,7 +105,7 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
replaced = true;
}
}
- grpc_exec_ctx_finish();
+
if (!replaced) {
args_.push_back(mutator_arg);
}
diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc
index 4e32298da4..739ab86bb2 100644
--- a/test/core/backoff/backoff_test.cc
+++ b/test/core/backoff/backoff_test.cc
@@ -34,19 +34,18 @@ static void test_constant_backoff(void) {
min_connect_timeout, max_backoff);
ExecCtx _local_exec_ctx;
grpc_backoff_result next_deadlines = grpc_backoff_begin(&backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now() ==
+ GPR_ASSERT(next_deadlines.current_deadline - ExecCtx::Get()->Now() ==
initial_backoff);
- GPR_ASSERT(next_deadlines.next_attempt_start_time - grpc_exec_ctx_now() ==
+ GPR_ASSERT(next_deadlines.next_attempt_start_time - ExecCtx::Get()->Now() ==
initial_backoff);
for (int i = 0; i < 10000; i++) {
next_deadlines = grpc_backoff_step(&backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now() ==
+ GPR_ASSERT(next_deadlines.current_deadline - ExecCtx::Get()->Now() ==
initial_backoff);
- GPR_ASSERT(next_deadlines.next_attempt_start_time - grpc_exec_ctx_now() ==
+ GPR_ASSERT(next_deadlines.next_attempt_start_time - ExecCtx::Get()->Now() ==
initial_backoff);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
}
- grpc_exec_ctx_finish();
}
static void test_min_connect(void) {
@@ -62,13 +61,12 @@ static void test_min_connect(void) {
grpc_backoff_result next = grpc_backoff_begin(&backoff);
// Because the min_connect_timeout > initial_backoff, current_deadline is used
// as the deadline for the current attempt.
- GPR_ASSERT(next.current_deadline - grpc_exec_ctx_now() ==
+ GPR_ASSERT(next.current_deadline - ExecCtx::Get()->Now() ==
min_connect_timeout);
// ... while, if the current attempt fails, the next one will happen after
// initial_backoff.
- GPR_ASSERT(next.next_attempt_start_time - grpc_exec_ctx_now() ==
+ GPR_ASSERT(next.next_attempt_start_time - ExecCtx::Get()->Now() ==
initial_backoff);
- grpc_exec_ctx_finish();
}
static void test_no_jitter_backoff(void) {
@@ -83,48 +81,46 @@ static void test_no_jitter_backoff(void) {
// x_1 = 2
// x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
ExecCtx _local_exec_ctx;
- exec_ctx->now = 0;
- exec_ctx->now_is_valid = true;
+ ExecCtx::Get()->SetNow(0);
grpc_backoff_result next_deadlines = grpc_backoff_begin(&backoff);
GPR_ASSERT(next_deadlines.current_deadline ==
next_deadlines.next_attempt_start_time);
GPR_ASSERT(next_deadlines.current_deadline == 2);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 6);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 14);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 30);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 62);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 126);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 254);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 510);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 1022);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
// Hit the maximum timeout. From this point onwards, retries will increase
// only by max timeout.
GPR_ASSERT(next_deadlines.current_deadline == 1535);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 2048);
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 2561);
- grpc_exec_ctx_finish();
}
static void test_jitter_backoff(void) {
@@ -142,9 +138,9 @@ static void test_jitter_backoff(void) {
ExecCtx _local_exec_ctx;
grpc_backoff_result next_deadlines = grpc_backoff_begin(&backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now() ==
+ GPR_ASSERT(next_deadlines.current_deadline - ExecCtx::Get()->Now() ==
initial_backoff);
- GPR_ASSERT(next_deadlines.next_attempt_start_time - grpc_exec_ctx_now() ==
+ GPR_ASSERT(next_deadlines.next_attempt_start_time - ExecCtx::Get()->Now() ==
initial_backoff);
grpc_millis expected_next_lower_bound =
@@ -157,7 +153,7 @@ static void test_jitter_backoff(void) {
// next-now must be within (jitter*100)% of the current backoff (which
// increases by * multiplier up to max_backoff).
const grpc_millis timeout_millis =
- next_deadlines.current_deadline - grpc_exec_ctx_now();
+ next_deadlines.current_deadline - ExecCtx::Get()->Now();
GPR_ASSERT(timeout_millis >= expected_next_lower_bound);
GPR_ASSERT(timeout_millis <= expected_next_upper_bound);
current_backoff = GPR_MIN(
@@ -166,9 +162,8 @@ static void test_jitter_backoff(void) {
(grpc_millis)((double)current_backoff * (1 - jitter));
expected_next_upper_bound =
(grpc_millis)((double)current_backoff * (1 + jitter));
- exec_ctx->now = next_deadlines.current_deadline;
+ ExecCtx::Get()->SetNow(next_deadlines.current_deadline);
}
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc
index c7e074ae6f..bc9e65089c 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -60,7 +60,6 @@ static void server_setup_transport(void* ts, grpc_transport* transport) {
ExecCtx _local_exec_ctx;
grpc_server_setup_transport(a->server, transport, NULL,
grpc_server_get_channel_args(a->server));
- grpc_exec_ctx_finish();
}
static void read_done(void* arg, grpc_error* error) {
@@ -118,7 +117,6 @@ void grpc_run_bad_client_test(
transport = grpc_create_chttp2_transport(NULL, sfd.server, 0);
server_setup_transport(&a, transport);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
/* Bind everything into the same pollset */
grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(a.cq));
@@ -137,7 +135,6 @@ void grpc_run_bad_client_test(
/* Write data */
grpc_endpoint_write(sfd.client, &outgoing, &done_write_closure);
- grpc_exec_ctx_finish();
/* Await completion, unless the request is large and write may not finish
* before the peer shuts down. */
@@ -150,7 +147,7 @@ void grpc_run_bad_client_test(
grpc_endpoint_shutdown(
sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect"));
grpc_endpoint_destroy(sfd.client);
- grpc_exec_ctx_finish();
+
sfd.client = NULL;
}
@@ -170,7 +167,7 @@ void grpc_run_bad_client_test(
GRPC_CLOSURE_INIT(&read_done_closure, read_done, &read_done_event,
grpc_schedule_on_exec_ctx);
grpc_endpoint_read(sfd.client, &incoming, &read_done_closure);
- grpc_exec_ctx_finish();
+
do {
GPR_ASSERT(gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0);
GPR_ASSERT(grpc_completion_queue_next(
@@ -188,7 +185,6 @@ void grpc_run_bad_client_test(
grpc_endpoint_shutdown(
sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
grpc_endpoint_destroy(sfd.client);
- grpc_exec_ctx_finish();
}
GPR_ASSERT(
@@ -203,6 +199,5 @@ void grpc_run_bad_client_test(
grpc_completion_queue_destroy(a.cq);
grpc_slice_buffer_destroy_internal(&outgoing);
- grpc_exec_ctx_finish();
grpc_shutdown();
}
diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc
index 03b1cbf265..f0393b0f40 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -56,7 +56,6 @@ static void test_create(void) {
0);
grpc_channel_args_destroy(ch_args);
- grpc_exec_ctx_finish();
}
static void test_set_compression_algorithm(void) {
@@ -71,7 +70,6 @@ static void test_set_compression_algorithm(void) {
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_INTEGER);
grpc_channel_args_destroy(ch_args);
- grpc_exec_ctx_finish();
}
static void test_compression_algorithm_states(void) {
@@ -123,7 +121,6 @@ static void test_compression_algorithm_states(void) {
}
grpc_channel_args_destroy(ch_args);
- grpc_exec_ctx_finish();
}
static void test_set_socket_mutator(void) {
@@ -139,7 +136,6 @@ static void test_set_socket_mutator(void) {
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(ch_args);
- grpc_exec_ctx_finish();
}
}
diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc
index 0433758905..66ee2948b1 100644
--- a/test/core/channel/channel_stack_test.cc
+++ b/test/core/channel/channel_stack_test.cc
@@ -138,13 +138,12 @@ static void test_create_channel_stack(void) {
GPR_ASSERT(*channel_data == 1);
GRPC_CALL_STACK_UNREF(call_stack, "done");
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(*channel_data == 2);
GRPC_CHANNEL_STACK_UNREF(channel_stack, "done");
grpc_slice_unref_internal(path);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc
index f35557324f..dd3c70a261 100644
--- a/test/core/channel/minimal_stack_is_minimal_test.cc
+++ b/test/core/channel/minimal_stack_is_minimal_test.cc
@@ -128,7 +128,6 @@ static int check_stack(const char* file, int line, const char* transport_name,
grpc_channel_stack_builder_set_channel_arguments(builder, channel_args);
GPR_ASSERT(grpc_channel_init_create_stack(
builder, (grpc_channel_stack_type)channel_stack_type));
- grpc_exec_ctx_finish();
}
// build up our expectation list
@@ -213,7 +212,6 @@ static int check_stack(const char* file, int line, const char* transport_name,
ExecCtx _local_exec_ctx;
grpc_channel_stack_builder_destroy(builder);
grpc_channel_args_destroy(channel_args);
- grpc_exec_ctx_finish();
}
return result;
diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc
index aabe8dea3c..5b412cc622 100644
--- a/test/core/client_channel/lb_policies_test.cc
+++ b/test/core/client_channel/lb_policies_test.cc
@@ -653,7 +653,6 @@ static void test_get_channel_info() {
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(args);
- grpc_exec_ctx_finish();
}
// Ensures that resolver returns.
grpc_channel_check_connectivity_state(channel, true /* try_to_connect */);
@@ -1025,7 +1024,6 @@ int main(int argc, char** argv) {
test_ping();
test_get_channel_info();
- grpc_exec_ctx_finish();
grpc_shutdown();
return 0;
}
diff --git a/test/core/client_channel/parse_address_test.cc b/test/core/client_channel/parse_address_test.cc
index 17725ba5ff..597a1212c1 100644
--- a/test/core/client_channel/parse_address_test.cc
+++ b/test/core/client_channel/parse_address_test.cc
@@ -43,7 +43,6 @@ static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {
GPR_ASSERT(0 == strcmp(addr_un->sun_path, pathname));
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish();
}
#else /* GRPC_HAVE_UNIX_SOCKET */
@@ -68,7 +67,6 @@ static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
GPR_ASSERT(ntohs(addr_in->sin_port) == port);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish();
}
static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
@@ -88,7 +86,6 @@ static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
GPR_ASSERT(addr_in6->sin6_scope_id == scope_id);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
index e2823a4501..c7a0e029f2 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -106,7 +106,6 @@ static bool wait_loop(int deadline_seconds, gpr_event* ev) {
ExecCtx _local_exec_ctx;
grpc_timer_check(NULL);
- grpc_exec_ctx_finish();
}
return false;
}
@@ -154,7 +153,7 @@ int main(int argc, char** argv) {
call_resolver_next_after_locking(
resolver, &result,
GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(wait_loop(5, &ev1));
GPR_ASSERT(result == NULL);
@@ -163,14 +162,13 @@ int main(int argc, char** argv) {
call_resolver_next_after_locking(
resolver, &result,
GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(wait_loop(30, &ev2));
GPR_ASSERT(result != NULL);
grpc_channel_args_destroy(result);
GRPC_RESOLVER_UNREF(resolver, "test");
GRPC_COMBINER_UNREF(g_combiner, "test");
- grpc_exec_ctx_finish();
grpc_shutdown();
gpr_mu_destroy(&g_mu);
diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc
index 8b40360263..33916b59ec 100644
--- a/test/core/client_channel/resolvers/dns_resolver_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_test.cc
@@ -42,7 +42,6 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
GPR_ASSERT(resolver != NULL);
GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish();
}
static void test_fails(grpc_resolver_factory* factory, const char* string) {
@@ -59,7 +58,6 @@ static void test_fails(grpc_resolver_factory* factory, const char* string) {
resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver == NULL);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
@@ -84,7 +82,6 @@ int main(int argc, char** argv) {
{
ExecCtx _local_exec_ctx;
GRPC_COMBINER_UNREF(g_combiner, "test");
- grpc_exec_ctx_finish();
}
grpc_shutdown();
diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc
index ec49558f87..9a1971561c 100644
--- a/test/core/client_channel/resolvers/fake_resolver_test.cc
+++ b/test/core/client_channel/resolvers/fake_resolver_test.cc
@@ -109,7 +109,7 @@ static void test_fake_resolver() {
results);
grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_seconds_to_deadline(5)) != NULL);
@@ -144,7 +144,7 @@ static void test_fake_resolver() {
results_update);
grpc_resolver_next_locked(resolver, &on_res_arg_update.resolver_result,
on_resolution);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg_update.ev,
grpc_timeout_seconds_to_deadline(5)) != NULL);
@@ -153,14 +153,14 @@ static void test_fake_resolver() {
memset(&on_res_arg, 0, sizeof(on_res_arg));
grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_milliseconds_to_deadline(100)) ==
NULL);
GRPC_COMBINER_UNREF(combiner, "test_fake_resolver");
GRPC_RESOLVER_UNREF(resolver, "test_fake_resolver");
- grpc_exec_ctx_finish();
+
grpc_fake_resolver_response_generator_unref(response_generator);
}
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
index dbc8a965d5..70b3cbf5b7 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
@@ -63,7 +63,7 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
- grpc_exec_ctx_finish();
+
grpc_uri_destroy(uri);
}
@@ -81,7 +81,6 @@ static void test_fails(grpc_resolver_factory* factory, const char* string) {
resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver == NULL);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
@@ -114,7 +113,6 @@ int main(int argc, char** argv) {
{
ExecCtx _local_exec_ctx;
GRPC_COMBINER_UNREF(g_combiner, "test");
- grpc_exec_ctx_finish();
}
grpc_shutdown();
diff --git a/test/core/client_channel/uri_fuzzer_test.cc b/test/core/client_channel/uri_fuzzer_test.cc
index 805becad18..6c1e8cb137 100644
--- a/test/core/client_channel/uri_fuzzer_test.cc
+++ b/test/core/client_channel/uri_fuzzer_test.cc
@@ -38,7 +38,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if ((x = grpc_uri_parse(s, 1))) {
grpc_uri_destroy(x);
}
- grpc_exec_ctx_finish();
+
gpr_free(s);
return 0;
}
diff --git a/test/core/client_channel/uri_parser_test.cc b/test/core/client_channel/uri_parser_test.cc
index 591c642f4e..024c30faee 100644
--- a/test/core/client_channel/uri_parser_test.cc
+++ b/test/core/client_channel/uri_parser_test.cc
@@ -36,14 +36,13 @@ static void test_succeeds(const char* uri_text, const char* scheme,
GPR_ASSERT(0 == strcmp(path, uri->path));
GPR_ASSERT(0 == strcmp(query, uri->query));
GPR_ASSERT(0 == strcmp(fragment, uri->fragment));
- grpc_exec_ctx_finish();
+
grpc_uri_destroy(uri);
}
static void test_fails(const char* uri_text) {
ExecCtx _local_exec_ctx;
GPR_ASSERT(NULL == grpc_uri_parse(uri_text, 0));
- grpc_exec_ctx_finish();
}
static void test_query_parts() {
@@ -77,7 +76,7 @@ static void test_query_parts() {
GPR_ASSERT(NULL == grpc_uri_get_query_arg(uri, ""));
GPR_ASSERT(0 == strcmp("frag", uri->fragment));
- grpc_exec_ctx_finish();
+
grpc_uri_destroy(uri);
}
{
@@ -96,7 +95,6 @@ static void test_query_parts() {
GPR_ASSERT(0 == strcmp("bar", grpc_uri_get_query_arg(uri, "foo")));
GPR_ASSERT(0 == strcmp("", grpc_uri_get_query_arg(uri, "foobar")));
- grpc_exec_ctx_finish();
grpc_uri_destroy(uri);
}
{
@@ -114,7 +112,7 @@ static void test_query_parts() {
GPR_ASSERT(NULL == uri->query_parts);
GPR_ASSERT(NULL == uri->query_parts_values);
GPR_ASSERT(0 == strcmp("", uri->fragment));
- grpc_exec_ctx_finish();
+
grpc_uri_destroy(uri);
}
}
diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc
index dea8e33030..9ae6363d97 100644
--- a/test/core/compression/algorithm_test.cc
+++ b/test/core/compression/algorithm_test.cc
@@ -53,7 +53,6 @@ static void test_algorithm_mesh(void) {
GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING));
grpc_slice_unref_internal(mdstr);
GRPC_MDELEM_UNREF(mdelem);
- grpc_exec_ctx_finish();
}
/* test failure */
@@ -84,7 +83,6 @@ static void test_algorithm_failure(void) {
static_cast<int>(GRPC_COMPRESS_ALGORITHMS_COUNT) + 1)),
grpc_empty_slice()));
grpc_slice_unref_internal(mdstr);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/compression/message_compress_test.cc b/test/core/compression/message_compress_test.cc
index d642e056d8..a5dfdc884f 100644
--- a/test/core/compression/message_compress_test.cc
+++ b/test/core/compression/message_compress_test.cc
@@ -72,7 +72,6 @@ static void assert_passthrough(grpc_slice value,
{
ExecCtx _local_exec_ctx;
was_compressed = grpc_msg_compress(algorithm, &input, &compressed_raw);
- grpc_exec_ctx_finish();
}
GPR_ASSERT(input.count > 0);
@@ -94,7 +93,6 @@ static void assert_passthrough(grpc_slice value,
ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_msg_decompress(
was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed, &output));
- grpc_exec_ctx_finish();
}
final = grpc_slice_merge(output.slices, output.count);
@@ -158,7 +156,7 @@ static void test_tiny_data_compress(void) {
GPR_ASSERT(0 ==
grpc_msg_compress(static_cast<grpc_compression_algorithm>(i),
&input, &output));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(1 == output.count);
}
@@ -189,7 +187,6 @@ static void test_bad_decompression_data_crc(void) {
/* try (and fail) to decompress the corrupted compresed buffer */
GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_GZIP, &corrupted, &output));
- grpc_exec_ctx_finish();
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&corrupted);
@@ -210,7 +207,6 @@ static void test_bad_decompression_data_trailing_garbage(void) {
/* try (and fail) to decompress the invalid compresed buffer */
ExecCtx _local_exec_ctx;
GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
- grpc_exec_ctx_finish();
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -228,7 +224,6 @@ static void test_bad_decompression_data_stream(void) {
/* try (and fail) to decompress the invalid compresed buffer */
ExecCtx _local_exec_ctx;
GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
- grpc_exec_ctx_finish();
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -253,7 +248,6 @@ static void test_bad_compression_algorithm(void) {
GRPC_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_compressed);
- grpc_exec_ctx_finish();
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -279,7 +273,6 @@ static void test_bad_decompression_algorithm(void) {
GRPC_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_decompressed);
- grpc_exec_ctx_finish();
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
diff --git a/test/core/debug/stats_test.cc b/test/core/debug/stats_test.cc
index 8401618670..c7aaf68dd3 100644
--- a/test/core/debug/stats_test.cc
+++ b/test/core/debug/stats_test.cc
@@ -51,7 +51,6 @@ TEST(StatsTest, IncCounters) {
ExecCtx _local_exec_ctx;
GRPC_STATS_INC_COUNTER((grpc_stats_counters)i);
- grpc_exec_ctx_finish();
EXPECT_EQ(snapshot.delta().counters[i], 1);
}
@@ -62,7 +61,6 @@ TEST(StatsTest, IncSpecificCounter) {
ExecCtx _local_exec_ctx;
GRPC_STATS_INC_SYSCALL_POLL();
- grpc_exec_ctx_finish();
EXPECT_EQ(snapshot.delta().counters[GRPC_STATS_COUNTER_SYSCALL_POLL], 1);
}
@@ -96,7 +94,6 @@ TEST_P(HistogramTest, IncHistogram) {
ExecCtx _local_exec_ctx;
grpc_stats_inc_histogram[kHistogram](j);
- grpc_exec_ctx_finish();
auto delta = snapshot.delta();
diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc
index 9ae3d3cfbf..5e7e12643e 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -290,7 +290,7 @@ static void run_test(const char* response_payload,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
grpc_endpoint_destroy(state.tcp);
cleanup_rpc();
- grpc_exec_ctx_finish();
+
test_tcp_server_destroy(&test_server);
grpc_shutdown();
diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc
index 677e315112..1372c5a746 100644
--- a/test/core/end2end/connection_refused_test.cc
+++ b/test/core/end2end/connection_refused_test.cc
@@ -133,7 +133,6 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
{
ExecCtx _local_exec_ctx;
if (args != NULL) grpc_channel_args_destroy(args);
- grpc_exec_ctx_finish();
}
grpc_shutdown();
diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc
index c3c3e961e7..a43d963c54 100644
--- a/test/core/end2end/fixtures/h2_census.cc
+++ b/test/core/end2end/fixtures/h2_census.cc
@@ -76,7 +76,6 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(client_args);
- grpc_exec_ctx_finish();
}
}
@@ -93,7 +92,6 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
grpc_server_register_completion_queue(f->server, f->cq, NULL);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc
index f520b48fa3..3f9a87d0fc 100644
--- a/test/core/end2end/fixtures/h2_compress.cc
+++ b/test/core/end2end/fixtures/h2_compress.cc
@@ -68,7 +68,6 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f,
if (ffd->client_args_compression != NULL) {
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(ffd->client_args_compression);
- grpc_exec_ctx_finish();
}
ffd->client_args_compression = grpc_channel_args_set_compression_algorithm(
client_args, GRPC_COMPRESS_GZIP);
@@ -83,7 +82,6 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f,
if (ffd->server_args_compression != NULL) {
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(ffd->server_args_compression);
- grpc_exec_ctx_finish();
}
ffd->server_args_compression = grpc_channel_args_set_compression_algorithm(
server_args, GRPC_COMPRESS_GZIP);
@@ -104,7 +102,6 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) {
grpc_channel_args_destroy(ffd->server_args_compression);
gpr_free(ffd->localaddr);
gpr_free(ffd);
- grpc_exec_ctx_finish();
}
/* All test configurations */
diff --git a/test/core/end2end/fixtures/h2_fd.cc b/test/core/end2end/fixtures/h2_fd.cc
index 48e1b313fd..99bced8651 100644
--- a/test/core/end2end/fixtures/h2_fd.cc
+++ b/test/core/end2end/fixtures/h2_fd.cc
@@ -75,8 +75,6 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
f->client = grpc_insecure_channel_create_from_fd(
"fixture_client", sfd->fd_pair[0], client_args);
GPR_ASSERT(f->client);
-
- grpc_exec_ctx_finish();
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
@@ -90,8 +88,6 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_server_start(f->server);
grpc_server_add_insecure_channel_from_fd(f->server, NULL, sfd->fd_pair[1]);
-
- grpc_exec_ctx_finish();
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc
index 563e1e1ac2..e98df083f2 100644
--- a/test/core/end2end/fixtures/h2_full+workarounds.cc
+++ b/test/core/end2end/fixtures/h2_full+workarounds.cc
@@ -90,7 +90,6 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
grpc_channel_args_destroy(server_args_new);
- grpc_exec_ctx_finish();
}
void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
diff --git a/test/core/end2end/fixtures/h2_load_reporting.cc b/test/core/end2end/fixtures/h2_load_reporting.cc
index 74b5983364..84eb9e4513 100644
--- a/test/core/end2end/fixtures/h2_load_reporting.cc
+++ b/test/core/end2end/fixtures/h2_load_reporting.cc
@@ -79,7 +79,6 @@ void chttp2_init_server_load_reporting(grpc_end2end_test_fixture* f,
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
grpc_server_register_completion_queue(f->server, f->cq, NULL);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc
index 8ff7cb304c..9ffc5b7b7e 100644
--- a/test/core/end2end/fixtures/h2_oauth2.cc
+++ b/test/core/end2end/fixtures/h2_oauth2.cc
@@ -160,7 +160,6 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_channel_args_destroy(new_client_args);
grpc_channel_credentials_release(ssl_creds);
grpc_call_credentials_release(oauth2_creds);
- grpc_exec_ctx_finish();
}
static int fail_server_auth_check(grpc_channel_args* server_args) {
diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc
index 391de0bd0b..9e87a22962 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.cc
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc
@@ -55,7 +55,6 @@ static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
grpc_server_setup_transport(f->server, transport, NULL,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish();
}
typedef struct {
@@ -98,7 +97,6 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
@@ -113,7 +111,6 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
@@ -143,7 +140,6 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
grpc_init();
- grpc_exec_ctx_finish();
GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0));
GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1));
diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc
index 4e7eb3dbb8..fa69ad84cf 100644
--- a/test/core/end2end/fixtures/h2_sockpair.cc
+++ b/test/core/end2end/fixtures/h2_sockpair.cc
@@ -49,7 +49,6 @@ static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
grpc_server_setup_transport(f->server, transport, NULL,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish();
}
typedef struct {
@@ -92,7 +91,6 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
@@ -107,7 +105,6 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
index cfa32d4a27..a12d60575b 100644
--- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc
+++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
@@ -49,7 +49,6 @@ static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
grpc_server_setup_transport(f->server, transport, NULL,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish();
}
typedef struct {
@@ -103,7 +102,6 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
@@ -118,7 +116,6 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
grpc_chttp2_transport_start_reading(transport, NULL);
- grpc_exec_ctx_finish();
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc
index ac555d9ee8..c137cec8b9 100644
--- a/test/core/end2end/fixtures/h2_ssl.cc
+++ b/test/core/end2end/fixtures/h2_ssl.cc
@@ -112,7 +112,6 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(new_client_args);
- grpc_exec_ctx_finish();
}
}
diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc
index 66c5b167e1..0c130d6ae1 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.cc
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc
@@ -68,7 +68,6 @@ static grpc_channel* create_proxy_client(const char* target,
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(new_client_args);
- grpc_exec_ctx_finish();
}
return channel;
}
@@ -150,7 +149,6 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(new_client_args);
- grpc_exec_ctx_finish();
}
}
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index b3ec44d77b..73a3e2c444 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -391,7 +391,7 @@ static void on_read_request_done(void* arg, grpc_error* error) {
GPR_ASSERT(resolved_addresses->naddrs >= 1);
// Connect to requested address.
// The connection callback inherits our reference to conn.
- const grpc_millis deadline = grpc_exec_ctx_now() + 10 * GPR_MS_PER_SEC;
+ const grpc_millis deadline = ExecCtx::Get()->Now() + 10 * GPR_MS_PER_SEC;
grpc_tcp_client_connect(&conn->on_server_connect_done, &conn->server_endpoint,
conn->pollset_set, NULL,
&resolved_addresses->addrs[0], deadline);
@@ -449,13 +449,13 @@ static void thread_main(void* arg) {
gpr_ref(&proxy->users);
grpc_pollset_worker* worker = NULL;
gpr_mu_lock(proxy->mu);
- GRPC_LOG_IF_ERROR("grpc_pollset_work",
- grpc_pollset_work(proxy->pollset, &worker,
- grpc_exec_ctx_now() + GPR_MS_PER_SEC));
+ GRPC_LOG_IF_ERROR(
+ "grpc_pollset_work",
+ grpc_pollset_work(proxy->pollset, &worker,
+ ExecCtx::Get()->Now() + GPR_MS_PER_SEC));
gpr_mu_unlock(proxy->mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
} while (!gpr_unref(&proxy->users));
- grpc_exec_ctx_finish();
}
grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
@@ -489,7 +489,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
proxy->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(proxy->pollset, &proxy->mu);
grpc_tcp_server_start(proxy->server, &proxy->pollset, 1, on_accept, proxy);
- grpc_exec_ctx_finish();
+
// Start proxy thread.
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
@@ -516,7 +516,6 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) {
grpc_schedule_on_exec_ctx));
GRPC_COMBINER_UNREF(proxy->combiner, "test");
gpr_free(proxy);
- grpc_exec_ctx_finish();
}
const char* grpc_end2end_http_proxy_get_proxy_name(
diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc
index 1d6a40c7e3..1d22ba3a42 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -411,7 +411,7 @@ void my_resolve_address(const char* addr, const char* default_port,
r->addrs = addresses;
r->lb_addrs = NULL;
grpc_timer_init(
- &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(),
+ &r->timer, GPR_MS_PER_SEC + ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
}
@@ -428,7 +428,7 @@ grpc_ares_request* my_dns_lookup_ares(const char* dns_server, const char* addr,
r->addrs = NULL;
r->lb_addrs = lb_addrs;
grpc_timer_init(
- &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(),
+ &r->timer, GPR_MS_PER_SEC + ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
return NULL;
}
@@ -488,7 +488,7 @@ static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
fc->ep = ep;
fc->deadline = deadline;
grpc_timer_init(
- &fc->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(),
+ &fc->timer, GPR_MS_PER_SEC + ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx));
}
@@ -745,7 +745,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
{
ExecCtx _local_exec_ctx;
grpc_executor_set_threading(false);
- grpc_exec_ctx_finish();
}
grpc_resolve_address = my_resolve_address;
grpc_dns_lookup_ares = my_dns_lookup_ares;
@@ -840,7 +839,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(args);
- grpc_exec_ctx_finish();
}
gpr_free(target_uri);
gpr_free(target);
@@ -868,7 +866,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(args);
- grpc_exec_ctx_finish();
}
grpc_server_register_completion_queue(g_server, cq, NULL);
grpc_server_start(g_server);
@@ -1197,7 +1194,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(args);
- grpc_exec_ctx_finish();
}
gpr_free(target_uri);
gpr_free(target);
diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc
index 219c42847e..95ed2fcdac 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.cc
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -111,7 +111,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_event ev;
while (1) {
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
switch (ev.type) {
case GRPC_QUEUE_TIMEOUT:
diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc
index d7295f4c83..21778c0a67 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.cc
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -78,7 +78,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_event ev;
while (1) {
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
switch (ev.type) {
case GRPC_QUEUE_TIMEOUT:
diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc
index 850d6516f2..e0da548a75 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -183,7 +183,6 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype;
{ \
ExecCtx _local_exec_ctx; \
grpc_channel_args_destroy(new_client_args); \
- grpc_exec_ctx_finish(); \
} \
}
diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc
index fcf30f0cc6..ffafb1f1e9 100644
--- a/test/core/end2end/tests/cancel_after_accept.cc
+++ b/test/core/end2end/tests/cancel_after_accept.cc
@@ -247,7 +247,6 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
if (args != NULL) {
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(args);
- grpc_exec_ctx_finish();
}
cq_verifier_destroy(cqv);
diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc
index b63491c7d2..7e20487f8b 100644
--- a/test/core/end2end/tests/cancel_after_round_trip.cc
+++ b/test/core/end2end/tests/cancel_after_round_trip.cc
@@ -279,7 +279,6 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
if (args != NULL) {
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(args);
- grpc_exec_ctx_finish();
}
cq_verifier_destroy(cqv);
diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc
index a85fdf2662..f04addbe9e 100644
--- a/test/core/end2end/tests/compressed_payload.cc
+++ b/test/core/end2end/tests/compressed_payload.cc
@@ -132,7 +132,6 @@ static void request_for_disabled_algorithm(
ExecCtx _local_exec_ctx;
server_args = grpc_channel_args_compression_algorithm_set_state(
&server_args, algorithm_to_disable, false);
- grpc_exec_ctx_finish();
}
f = begin_test(config, test_name, client_args, server_args);
@@ -260,7 +259,6 @@ static void request_for_disabled_algorithm(
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
end_test(&f);
@@ -539,7 +537,6 @@ static void request_with_payload_template(
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
end_test(&f);
diff --git a/test/core/end2end/tests/load_reporting_hook.cc b/test/core/end2end/tests/load_reporting_hook.cc
index 670610f37f..6ce22d77c6 100644
--- a/test/core/end2end/tests/load_reporting_hook.cc
+++ b/test/core/end2end/tests/load_reporting_hook.cc
@@ -302,7 +302,6 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) {
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(lr_server_args);
- grpc_exec_ctx_finish();
}
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc
index 0200517de3..f884d8b11f 100644
--- a/test/core/end2end/tests/max_message_length.cc
+++ b/test/core/end2end/tests/max_message_length.cc
@@ -176,7 +176,6 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
ExecCtx _local_exec_ctx;
if (client_args != NULL) grpc_channel_args_destroy(client_args);
if (server_args != NULL) grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
cqv = cq_verifier_create(f.cq);
@@ -367,7 +366,6 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
ExecCtx _local_exec_ctx;
if (client_args != NULL) grpc_channel_args_destroy(client_args);
if (server_args != NULL) grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
cqv = cq_verifier_create(f.cq);
diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc
index 6100d604d2..cec46305bd 100644
--- a/test/core/end2end/tests/stream_compression_compressed_payload.cc
+++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc
@@ -132,7 +132,6 @@ static void request_for_disabled_algorithm(
ExecCtx _local_exec_ctx;
server_args = grpc_channel_args_stream_compression_algorithm_set_state(
&server_args, algorithm_to_disable, false);
- grpc_exec_ctx_finish();
}
f = begin_test(config, test_name, client_args, server_args);
@@ -261,7 +260,6 @@ static void request_for_disabled_algorithm(
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
end_test(&f);
@@ -547,7 +545,6 @@ static void request_with_payload_template(
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
end_test(&f);
diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc
index 42318ffbc8..c304c990d7 100644
--- a/test/core/end2end/tests/stream_compression_payload.cc
+++ b/test/core/end2end/tests/stream_compression_payload.cc
@@ -280,7 +280,6 @@ static void test_invoke_request_response_with_payload(
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
}
diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
index 5fb6a7e46f..f4b737d7a3 100644
--- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
+++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
@@ -276,7 +276,6 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
}
diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc
index f38a51a5b7..100f393b8e 100644
--- a/test/core/end2end/tests/workaround_cronet_compression.cc
+++ b/test/core/end2end/tests/workaround_cronet_compression.cc
@@ -150,7 +150,6 @@ static void request_with_payload_template(
arg.value.string = user_agent_override;
client_args = grpc_channel_args_copy_and_add(client_args_old, &arg, 1);
grpc_channel_args_destroy(client_args_old);
- grpc_exec_ctx_finish();
}
f = begin_test(config, test_name, client_args, server_args);
@@ -352,7 +351,6 @@ static void request_with_payload_template(
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(server_args);
- grpc_exec_ctx_finish();
}
end_test(&f);
diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc
index 85e4bc8a0e..dfa328360d 100644
--- a/test/core/http/httpcli_test.cc
+++ b/test/core/http/httpcli_test.cc
@@ -88,7 +88,7 @@ static void test_get(int port) {
"pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
&worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -127,7 +127,7 @@ static void test_post(int port) {
"pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
&worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -196,7 +196,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(grpc_polling_entity_pollset(&g_pops));
diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc
index d948bb5e31..ff082e8367 100644
--- a/test/core/http/httpscli_test.cc
+++ b/test/core/http/httpscli_test.cc
@@ -89,7 +89,7 @@ static void test_get(int port) {
"pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
&worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -129,7 +129,7 @@ static void test_post(int port) {
"pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
&worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -199,7 +199,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(grpc_polling_entity_pollset(&g_pops));
diff --git a/test/core/iomgr/combiner_test.cc b/test/core/iomgr/combiner_test.cc
index 9fc1890c97..df8d55f1f6 100644
--- a/test/core/iomgr/combiner_test.cc
+++ b/test/core/iomgr/combiner_test.cc
@@ -30,7 +30,6 @@ static void test_no_op(void) {
gpr_log(GPR_DEBUG, "test_no_op");
ExecCtx _local_exec_ctx;
GRPC_COMBINER_UNREF(grpc_combiner_create(), "test_no_op");
- grpc_exec_ctx_finish();
}
static void set_event_to_true(void* value, grpc_error* error) {
@@ -47,11 +46,10 @@ static void test_execute_one(void) {
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &done,
grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&done, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
GRPC_COMBINER_UNREF(lock, "test_execute_one");
- grpc_exec_ctx_finish();
}
typedef struct {
@@ -84,7 +82,7 @@ static void execute_many_loop(void* a) {
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(
check_one, c, grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
// sleep for a little bit, to test a combiner draining and another thread
// picking it up
@@ -93,7 +91,6 @@ static void execute_many_loop(void* a) {
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &args->done,
grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_finish();
}
static void test_execute_many(void) {
@@ -117,7 +114,6 @@ static void test_execute_many(void) {
}
ExecCtx _local_exec_ctx;
GRPC_COMBINER_UNREF(lock, "test_execute_many");
- grpc_exec_ctx_finish();
}
static gpr_event got_in_finally;
@@ -142,11 +138,10 @@ static void test_execute_finally(void) {
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_CREATE(add_finally, lock, grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&got_in_finally,
grpc_timeout_seconds_to_deadline(5)) != NULL);
GRPC_COMBINER_UNREF(lock, "test_execute_finally");
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/iomgr/endpoint_pair_test.cc b/test/core/iomgr/endpoint_pair_test.cc
index bddeadd329..72833a8dbe 100644
--- a/test/core/iomgr/endpoint_pair_test.cc
+++ b/test/core/iomgr/endpoint_pair_test.cc
@@ -45,7 +45,6 @@ static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
f.server_ep = p.server;
grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
- grpc_exec_ctx_finish();
return f;
}
@@ -69,7 +68,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc
index 10e80fc71b..5c156ef524 100644
--- a/test/core/iomgr/endpoint_tests.cc
+++ b/test/core/iomgr/endpoint_tests.cc
@@ -213,7 +213,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
even when bytes_written is unsigned. */
state.bytes_written -= state.current_write_size;
read_and_write_test_write_handler(&state, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_endpoint_read(state.read_ep, &state.incoming, &state.done_read);
@@ -225,24 +225,23 @@ static void read_and_write_test(grpc_endpoint_test_config config,
grpc_endpoint_shutdown(
state.write_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
}
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
while (!state.read_done || !state.write_done) {
grpc_pollset_worker* worker = NULL;
- GPR_ASSERT(grpc_exec_ctx_now() < deadline);
+ GPR_ASSERT(ExecCtx::Get()->Now() < deadline);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
end_test(config);
grpc_slice_buffer_destroy_internal(&state.outgoing);
grpc_slice_buffer_destroy_internal(&state.incoming);
grpc_endpoint_destroy(state.read_ep);
grpc_endpoint_destroy(state.write_ep);
- grpc_exec_ctx_finish();
}
static void inc_on_failure(void* arg, grpc_error* error) {
@@ -253,16 +252,16 @@ static void inc_on_failure(void* arg, grpc_error* error) {
}
static void wait_for_fail_count(int* fail_count, int want_fail_count) {
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
- while (grpc_exec_ctx_now() < deadline && *fail_count < want_fail_count) {
+ while (ExecCtx::Get()->Now() < deadline && *fail_count < want_fail_count) {
grpc_pollset_worker* worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(*fail_count == want_fail_count);
@@ -303,7 +302,6 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) {
grpc_endpoint_destroy(f.client_ep);
grpc_endpoint_destroy(f.server_ep);
- grpc_exec_ctx_finish();
}
void grpc_endpoint_tests(grpc_endpoint_test_config config,
diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc
index 5dd28eac9c..5c71bc6152 100644
--- a/test/core/iomgr/ev_epollsig_linux_test.cc
+++ b/test/core/iomgr/ev_epollsig_linux_test.cc
@@ -77,11 +77,11 @@ static void test_fd_cleanup(test_fd* tfds, int num_fds) {
for (i = 0; i < num_fds; i++) {
grpc_fd_shutdown(tfds[i].fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_fd_cleanup"));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_fd_orphan(tfds[i].fd, NULL, &release_fd, false /* already_closed */,
"test_fd_cleanup");
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(release_fd == tfds[i].inner_fd);
close(tfds[i].inner_fd);
@@ -110,7 +110,7 @@ static void test_pollset_cleanup(test_pollset* pollsets, int num_pollsets) {
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(pollsets[i].pollset, &destroyed);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_free(pollsets[i].pollset);
}
}
@@ -168,32 +168,32 @@ static void test_add_fd_to_pollset() {
/* == Step 1 == */
for (i = 0; i <= 2; i++) {
grpc_pollset_add_fd(pollsets[0].pollset, tfds[i].fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
for (i = 3; i <= 4; i++) {
grpc_pollset_add_fd(pollsets[1].pollset, tfds[i].fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
for (i = 5; i <= 7; i++) {
grpc_pollset_add_fd(pollsets[2].pollset, tfds[i].fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
/* == Step 2 == */
for (i = 0; i <= 1; i++) {
grpc_pollset_add_fd(pollsets[3].pollset, tfds[i].fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
/* == Step 3 == */
grpc_pollset_add_fd(pollsets[1].pollset, tfds[0].fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* == Step 4 == */
grpc_pollset_add_fd(pollsets[2].pollset, tfds[3].fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* All polling islands are merged at this point */
@@ -212,7 +212,6 @@ static void test_add_fd_to_pollset() {
test_fd_cleanup(tfds, NUM_FDS);
test_pollset_cleanup(pollsets, NUM_POLLSETS);
- grpc_exec_ctx_finish();
}
#undef NUM_FDS
@@ -239,7 +238,6 @@ static void test_threading_loop(void* arg) {
"pollset_work",
grpc_pollset_work(shared->pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(shared->mu);
- grpc_exec_ctx_finish();
}
}
@@ -279,7 +277,6 @@ static void test_threading(void) {
shared.wakeup_desc,
GRPC_CLOSURE_INIT(&shared.on_wakeup, test_threading_wakeup, &shared,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish();
}
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_first",
grpc_wakeup_fd_wakeup(shared.wakeup_fd)));
@@ -296,7 +293,6 @@ static void test_threading(void) {
grpc_pollset_shutdown(shared.pollset,
GRPC_CLOSURE_CREATE(destroy_pollset, shared.pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish();
}
gpr_free(shared.pollset);
}
@@ -318,7 +314,6 @@ int main(int argc, char** argv) {
poll_strategy);
}
- grpc_exec_ctx_finish();
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/fd_conservation_posix_test.cc b/test/core/iomgr/fd_conservation_posix_test.cc
index a5f6d33998..7f3420269e 100644
--- a/test/core/iomgr/fd_conservation_posix_test.cc
+++ b/test/core/iomgr/fd_conservation_posix_test.cc
@@ -45,12 +45,11 @@ int main(int argc, char** argv) {
p = grpc_iomgr_create_endpoint_pair("test", NULL);
grpc_endpoint_destroy(p.client);
grpc_endpoint_destroy(p.server);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
grpc_resource_quota_unref(resource_quota);
- grpc_exec_ctx_finish();
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc
index 9bf16923cb..d22cb5f4f6 100644
--- a/test/core/iomgr/fd_posix_test.cc
+++ b/test/core/iomgr/fd_posix_test.cc
@@ -252,7 +252,7 @@ static void server_wait_and_shutdown(server* sv) {
"pollset_work",
grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -367,7 +367,7 @@ static void client_wait_and_shutdown(client* cl) {
"pollset_work",
grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -386,7 +386,7 @@ static void test_grpc_fd(void) {
port = server_start(&sv);
client_init(&cl);
client_start(&cl, port);
- grpc_exec_ctx_finish();
+
client_wait_and_shutdown(&cl);
server_wait_and_shutdown(&sv);
GPR_ASSERT(sv.read_bytes_total == cl.write_bytes_total);
@@ -469,7 +469,7 @@ static void test_grpc_fd_change(void) {
"pollset_work",
grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(a.cb_that_ran == first_read_callback);
@@ -493,7 +493,7 @@ static void test_grpc_fd_change(void) {
"pollset_work",
grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
/* Except now we verify that second_read_callback ran instead */
@@ -501,7 +501,7 @@ static void test_grpc_fd_change(void) {
gpr_mu_unlock(g_mu);
grpc_fd_orphan(em_fd, NULL, NULL, false /* already_closed */, "d");
- grpc_exec_ctx_finish();
+
destroy_change_data(&a);
destroy_change_data(&b);
close(sv[1]);
@@ -523,9 +523,9 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_free(g_pollset);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc
index ba794ca192..e9b46f59e3 100644
--- a/test/core/iomgr/pollset_set_test.cc
+++ b/test/core/iomgr/pollset_set_test.cc
@@ -84,7 +84,7 @@ static void cleanup_test_pollsets(test_pollset* pollsets,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(pollsets[i].ps, &destroyed);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_free(pollsets[i].ps);
pollsets[i].ps = NULL;
}
@@ -129,7 +129,7 @@ static void cleanup_test_fds(test_fd* tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
grpc_fd_shutdown(tfds[i].fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("fd cleanup"));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* grpc_fd_orphan frees the memory allocated for grpc_fd. Normally it also
* calls close() on the underlying fd. In our case, we are using
@@ -138,7 +138,7 @@ static void cleanup_test_fds(test_fd* tfds, const int num_fds) {
* underlying fd, call it with a non-NULL 'release_fd' parameter */
grpc_fd_orphan(tfds[i].fd, NULL, &release_fd, false /* already_closed */,
"test_fd_cleanup");
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_wakeup_fd_destroy(&tfds[i].wakeup_fd);
}
@@ -236,7 +236,7 @@ static void pollset_set_test_basic() {
grpc_pollset_add_fd(pollsets[1].ps, tfds[8].fd);
grpc_pollset_add_fd(pollsets[2].ps, tfds[9].fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Test that if any FD in the above structure is readable, it is observable by
* doing grpc_pollset_work on any pollset
@@ -259,10 +259,10 @@ static void pollset_set_test_basic() {
grpc_pollset_work(pollsets[i].ps, &worker, deadline));
gpr_mu_unlock(pollsets[i].mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
verify_readable_and_reset(tfds, num_fds);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
/* Test tear down */
@@ -270,19 +270,18 @@ static void pollset_set_test_basic() {
grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[5].fd);
grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[1].fd);
grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[6].fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_pollset_set_del_pollset(pollset_sets[1].pss, pollsets[0].ps);
grpc_pollset_set_del_pollset(pollset_sets[0].pss, pollsets[1].ps);
grpc_pollset_set_del_pollset(pollset_sets[0].pss, pollsets[2].ps);
grpc_pollset_set_del_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
cleanup_test_fds(tfds, num_fds);
cleanup_test_pollsets(pollsets, num_ps);
cleanup_test_pollset_sets(pollset_sets, num_pss);
- grpc_exec_ctx_finish();
}
/* Same FD added multiple times to the pollset_set tree */
@@ -338,10 +337,10 @@ void pollset_set_test_dup_fds() {
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_pollset_work(pollset.ps, &worker, deadline));
gpr_mu_unlock(pollset.mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
verify_readable_and_reset(tfds, num_fds);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Tear down */
grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
@@ -350,12 +349,11 @@ void pollset_set_test_dup_fds() {
grpc_pollset_set_del_pollset(pollset_sets[1].pss, pollset.ps);
grpc_pollset_set_del_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
cleanup_test_fds(tfds, num_fds);
cleanup_test_pollsets(&pollset, num_ps);
cleanup_test_pollset_sets(pollset_sets, num_pss);
- grpc_exec_ctx_finish();
}
/* Pollset_set with an empty pollset */
@@ -406,21 +404,20 @@ void pollset_set_test_empty_pollset() {
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_pollset_work(pollsets[0].ps, &worker, deadline));
gpr_mu_unlock(pollsets[0].mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
verify_readable_and_reset(tfds, num_fds);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Tear down */
grpc_pollset_set_del_fd(pollset_set.pss, tfds[0].fd);
grpc_pollset_set_del_pollset(pollset_set.pss, pollsets[0].ps);
grpc_pollset_set_del_pollset(pollset_set.pss, pollsets[1].ps);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
cleanup_test_fds(tfds, num_fds);
cleanup_test_pollsets(pollsets, num_ps);
cleanup_test_pollset_sets(&pollset_set, num_pss);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
@@ -442,7 +439,6 @@ int main(int argc, char** argv) {
poll_strategy);
}
- grpc_exec_ctx_finish();
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc
index d06777d86f..9870d7aa73 100644
--- a/test/core/iomgr/resolve_address_posix_test.cc
+++ b/test/core/iomgr/resolve_address_posix_test.cc
@@ -67,7 +67,7 @@ void args_finish(args_struct* args) {
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(args->pollset, &do_nothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
}
@@ -86,7 +86,7 @@ static void actually_poll(void* argsp) {
if (done) {
break;
}
- grpc_millis time_left = deadline - grpc_exec_ctx_now();
+ grpc_millis time_left = deadline - ExecCtx::Get()->Now();
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = NULL;
@@ -94,10 +94,9 @@ static void actually_poll(void* argsp) {
GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(args->pollset, &worker,
n_sec_deadline(1)));
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
gpr_event_set(&args->ev, (void*)1);
- grpc_exec_ctx_finish();
}
static void poll_pollset_until_request_done(args_struct* args) {
@@ -130,7 +129,6 @@ static void test_unix_socket(void) {
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
args_finish(&args);
- grpc_exec_ctx_finish();
}
static void test_unix_socket_path_name_too_long(void) {
@@ -153,7 +151,6 @@ static void test_unix_socket_path_name_too_long(void) {
&args.addrs);
gpr_free(path_name);
args_finish(&args);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
@@ -163,7 +160,7 @@ int main(int argc, char** argv) {
test_unix_socket();
test_unix_socket_path_name_too_long();
grpc_executor_shutdown();
- grpc_exec_ctx_finish();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc
index 1eb753dc85..dbc825884d 100644
--- a/test/core/iomgr/resolve_address_test.cc
+++ b/test/core/iomgr/resolve_address_test.cc
@@ -63,7 +63,7 @@ void args_finish(args_struct* args) {
grpc_pollset_shutdown(args->pollset, &do_nothing_cb);
gpr_mu_unlock(args->mu);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
}
@@ -81,7 +81,7 @@ static void poll_pollset_until_request_done(args_struct* args) {
if (done) {
break;
}
- grpc_millis time_left = deadline - grpc_exec_ctx_now();
+ grpc_millis time_left = deadline - ExecCtx::Get()->Now();
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = NULL;
@@ -89,10 +89,9 @@ static void poll_pollset_until_request_done(args_struct* args) {
GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(args->pollset, &worker,
n_sec_deadline(1)));
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
gpr_event_set(&args->ev, (void*)1);
- grpc_exec_ctx_finish();
}
static void must_succeed(void* argsp, grpc_error* err) {
@@ -123,10 +122,9 @@ static void test_localhost(void) {
"localhost:1", NULL, args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
args_finish(&args);
- grpc_exec_ctx_finish();
}
static void test_default_port(void) {
@@ -137,10 +135,9 @@ static void test_default_port(void) {
"localhost", "1", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
args_finish(&args);
- grpc_exec_ctx_finish();
}
static void test_non_numeric_default_port(void) {
@@ -151,10 +148,9 @@ static void test_non_numeric_default_port(void) {
"localhost", "https", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
args_finish(&args);
- grpc_exec_ctx_finish();
}
static void test_missing_default_port(void) {
@@ -165,10 +161,9 @@ static void test_missing_default_port(void) {
"localhost", NULL, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
args_finish(&args);
- grpc_exec_ctx_finish();
}
static void test_ipv6_with_port(void) {
@@ -179,10 +174,9 @@ static void test_ipv6_with_port(void) {
"[2001:db8::1]:1", NULL, args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
args_finish(&args);
- grpc_exec_ctx_finish();
}
static void test_ipv6_without_port(void) {
@@ -200,10 +194,9 @@ static void test_ipv6_without_port(void) {
kCases[i], "80", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
args_finish(&args);
- grpc_exec_ctx_finish();
}
}
@@ -221,10 +214,9 @@ static void test_invalid_ip_addresses(void) {
kCases[i], NULL, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
args_finish(&args);
- grpc_exec_ctx_finish();
}
}
@@ -241,10 +233,9 @@ static void test_unparseable_hostports(void) {
kCases[i], "1", args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
args_finish(&args);
- grpc_exec_ctx_finish();
}
}
@@ -261,7 +252,7 @@ int main(int argc, char** argv) {
test_invalid_ip_addresses();
test_unparseable_hostports();
grpc_executor_shutdown();
- grpc_exec_ctx_finish();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc
index bee9373ff6..40beadc5d6 100644
--- a/test/core/iomgr/resource_quota_test.cc
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -86,7 +86,6 @@ grpc_closure* make_unused_reclaimer(grpc_closure* then) {
static void destroy_user(grpc_resource_user* usr) {
ExecCtx _local_exec_ctx;
grpc_resource_user_unref(usr);
- grpc_exec_ctx_finish();
}
static void test_no_op(void) {
@@ -120,12 +119,10 @@ static void test_instant_alloc_then_free(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, NULL);
- grpc_exec_ctx_finish();
}
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -141,7 +138,6 @@ static void test_instant_alloc_free_pair(void) {
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, NULL);
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -158,14 +154,13 @@ static void test_simple_async_alloc(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
}
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -182,7 +177,7 @@ static void test_async_alloc_blocked_by_size(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(
&ev, grpc_timeout_milliseconds_to_deadline(100)) == NULL);
}
@@ -192,7 +187,6 @@ static void test_async_alloc_blocked_by_size(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -209,7 +203,7 @@ static void test_scavenge(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -217,14 +211,13 @@ static void test_scavenge(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr1, 1024);
- grpc_exec_ctx_finish();
}
{
gpr_event ev;
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -232,7 +225,6 @@ static void test_scavenge(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr2, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -250,7 +242,7 @@ static void test_scavenge_blocked(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -259,14 +251,14 @@ static void test_scavenge_blocked(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(
&ev, grpc_timeout_milliseconds_to_deadline(100)) == NULL);
}
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr1, 1024);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -274,7 +266,6 @@ static void test_scavenge_blocked(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr2, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -292,7 +283,7 @@ static void test_blocked_until_scheduled_reclaim(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -303,14 +294,13 @@ static void test_blocked_until_scheduled_reclaim(void) {
ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
usr, false, make_reclaimer(usr, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish();
}
{
gpr_event ev;
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -320,7 +310,6 @@ static void test_blocked_until_scheduled_reclaim(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -338,7 +327,7 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -349,14 +338,13 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
usr1, false, make_reclaimer(usr1, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish();
}
{
gpr_event ev;
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -366,7 +354,6 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr2, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -384,7 +371,7 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -395,14 +382,13 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
usr, true, make_reclaimer(usr, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish();
}
{
gpr_event ev;
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -412,7 +398,6 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -434,7 +419,7 @@ static void test_unused_reclaim_is_cancelled(void) {
usr, false, make_unused_reclaimer(set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
usr, true, make_unused_reclaimer(set_event(&destructive_done)));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
NULL);
@@ -465,7 +450,7 @@ static void test_benign_reclaim_is_preferred(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -476,7 +461,7 @@ static void test_benign_reclaim_is_preferred(void) {
usr, false, make_reclaimer(usr, 1024, set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
usr, true, make_unused_reclaimer(set_event(&destructive_done)));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
NULL);
@@ -489,7 +474,7 @@ static void test_benign_reclaim_is_preferred(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&destructive_done,
@@ -501,7 +486,6 @@ static void test_benign_reclaim_is_preferred(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -526,7 +510,7 @@ static void test_multiple_reclaims_can_be_triggered(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
NULL);
;
@@ -537,7 +521,7 @@ static void test_multiple_reclaims_can_be_triggered(void) {
usr, false, make_reclaimer(usr, 512, set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
usr, true, make_reclaimer(usr, 512, set_event(&destructive_done)));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
NULL);
@@ -550,7 +534,7 @@ static void test_multiple_reclaims_can_be_triggered(void) {
gpr_event_init(&ev);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&destructive_done,
@@ -562,7 +546,6 @@ static void test_multiple_reclaims_can_be_triggered(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -582,18 +565,15 @@ static void test_resource_user_stays_allocated_until_memory_released(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, NULL);
- grpc_exec_ctx_finish();
}
{
ExecCtx _local_exec_ctx;
grpc_resource_quota_unref(q);
grpc_resource_user_unref(usr);
- grpc_exec_ctx_finish();
}
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
}
@@ -616,7 +596,7 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
usr, false, make_unused_reclaimer(set_event(&reclaimer_cancelled)));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
NULL);
@@ -626,7 +606,7 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
gpr_event_init(&allocated);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&allocated,
grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
@@ -636,7 +616,7 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
{
ExecCtx _local_exec_ctx;
grpc_resource_user_unref(usr);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
NULL);
@@ -644,7 +624,7 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_seconds_to_deadline(5)) != NULL);
}
@@ -663,7 +643,7 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
gpr_event_init(&allocated);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&allocated,
grpc_timeout_seconds_to_deadline(5)) != NULL);
}
@@ -674,7 +654,7 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
usr, false, make_reclaimer(usr, 1024, set_event(&reclaimer_done)));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
NULL);
@@ -684,7 +664,7 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
gpr_event_init(&allocated);
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish();
+
GPR_ASSERT(gpr_event_wait(&allocated,
grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
@@ -694,7 +674,6 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_free(usr, 1024);
- grpc_exec_ctx_finish();
}
destroy_user(usr);
grpc_resource_quota_unref(q);
@@ -719,14 +698,13 @@ static void test_one_slice(void) {
const int start_allocs = num_allocs;
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish();
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
{
ExecCtx _local_exec_ctx;
grpc_slice_buffer_destroy_internal(&buffer);
- grpc_exec_ctx_finish();
}
destroy_user(usr);
grpc_resource_quota_unref(q);
@@ -752,21 +730,19 @@ static void test_one_slice_deleted_late(void) {
const int start_allocs = num_allocs;
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish();
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
{
ExecCtx _local_exec_ctx;
grpc_resource_user_unref(usr);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
{
ExecCtx _local_exec_ctx;
grpc_slice_buffer_destroy_internal(&buffer);
- grpc_exec_ctx_finish();
}
}
@@ -796,7 +772,7 @@ static void test_negative_rq_free_pool(void) {
const int start_allocs = num_allocs;
ExecCtx _local_exec_ctx;
grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish();
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
@@ -809,14 +785,12 @@ static void test_negative_rq_free_pool(void) {
{
ExecCtx _local_exec_ctx;
grpc_resource_user_unref(usr);
- grpc_exec_ctx_finish();
}
grpc_resource_quota_unref(q);
{
ExecCtx _local_exec_ctx;
grpc_slice_buffer_destroy_internal(&buffer);
- grpc_exec_ctx_finish();
}
}
diff --git a/test/core/iomgr/tcp_client_posix_test.cc b/test/core/iomgr/tcp_client_posix_test.cc
index 7fad3b08be..abefecba33 100644
--- a/test/core/iomgr/tcp_client_posix_test.cc
+++ b/test/core/iomgr/tcp_client_posix_test.cc
@@ -56,7 +56,7 @@ static void finish_connection() {
ExecCtx _local_exec_ctx;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL)));
- grpc_exec_ctx_finish();
+
gpr_mu_unlock(g_mu);
}
@@ -127,13 +127,11 @@ void test_succeeds(void) {
grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
-
- grpc_exec_ctx_finish();
}
void test_fails(void) {
@@ -177,12 +175,11 @@ void test_fails(void) {
break;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
}
static void destroy_pollset(void* p, grpc_error* error) {
@@ -198,7 +195,7 @@ int main(int argc, char** argv) {
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(g_pollset, &g_mu);
grpc_pollset_set_add_pollset(g_pollset_set, g_pollset);
- grpc_exec_ctx_finish();
+
test_succeeds();
gpr_log(GPR_ERROR, "End of first test");
test_fails();
@@ -206,7 +203,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
diff --git a/test/core/iomgr/tcp_client_uv_test.cc b/test/core/iomgr/tcp_client_uv_test.cc
index dd98fb2275..0355896b85 100644
--- a/test/core/iomgr/tcp_client_uv_test.cc
+++ b/test/core/iomgr/tcp_client_uv_test.cc
@@ -121,7 +121,7 @@ void test_succeeds(void) {
grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
@@ -129,8 +129,6 @@ void test_succeeds(void) {
uv_close((uv_handle_t*)svr_handle, close_cb);
gpr_mu_unlock(g_mu);
-
- grpc_exec_ctx_finish();
}
void test_fails(void) {
@@ -175,12 +173,11 @@ void test_fails(void) {
break;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
}
static void destroy_pollset(void* p, grpc_error* error) {
@@ -194,14 +191,14 @@ int main(int argc, char** argv) {
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size()));
grpc_pollset_init(g_pollset, &g_mu);
- grpc_exec_ctx_finish();
+
test_succeeds();
gpr_log(GPR_ERROR, "End of first test");
test_fails();
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc
index e4126fb05a..678e1c3638 100644
--- a/test/core/iomgr/tcp_posix_test.cc
+++ b/test/core/iomgr/tcp_posix_test.cc
@@ -193,7 +193,7 @@ static void read_test(size_t num_bytes, size_t slice_size) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
@@ -201,7 +201,6 @@ static void read_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_destroy_internal(&state.incoming);
grpc_endpoint_destroy(ep);
- grpc_exec_ctx_finish();
}
/* Write to a socket until it fills up, then read from it using the grpc_tcp
@@ -244,7 +243,7 @@ static void large_read_test(size_t slice_size) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
@@ -252,7 +251,6 @@ static void large_read_test(size_t slice_size) {
grpc_slice_buffer_destroy_internal(&state.incoming);
grpc_endpoint_destroy(ep);
- grpc_exec_ctx_finish();
}
struct write_socket_state {
@@ -316,7 +314,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(10)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
do {
bytes_read =
read(fd, buf, bytes_left > read_size ? read_size : bytes_left);
@@ -385,7 +383,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -393,7 +391,6 @@ static void write_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_destroy_internal(&outgoing);
grpc_endpoint_destroy(ep);
gpr_free(slices);
- grpc_exec_ctx_finish();
}
void on_fd_released(void* arg, grpc_error* errors) {
@@ -453,7 +450,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
gpr_log(GPR_DEBUG, "wakeup: read=%" PRIdPTR " target=%" PRIdPTR,
state.read_bytes, state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
@@ -461,7 +458,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_destroy_internal(&state.incoming);
grpc_tcp_destroy_and_release_fd(ep, &fd, &fd_released_cb);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
while (!fd_released_done) {
grpc_pollset_worker* worker = NULL;
@@ -472,7 +469,6 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
gpr_mu_unlock(g_mu);
GPR_ASSERT(fd_released_done == 1);
GPR_ASSERT(fd == sv[1]);
- grpc_exec_ctx_finish();
written_bytes = fill_socket_partial(sv[0], num_bytes);
drain_socket_blocking(fd, written_bytes, written_bytes);
@@ -528,8 +524,6 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
- grpc_exec_ctx_finish();
-
return f;
}
@@ -553,7 +547,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc
index 3707634c29..1c3f4490d5 100644
--- a/test/core/iomgr/tcp_server_posix_test.cc
+++ b/test/core/iomgr/tcp_server_posix_test.cc
@@ -167,7 +167,6 @@ static void test_no_op(void) {
grpc_tcp_server* s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
}
static void test_no_op_with_start(void) {
@@ -177,7 +176,6 @@ static void test_no_op_with_start(void) {
LOG_TEST("test_no_op_with_start");
grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
}
static void test_no_op_with_port(void) {
@@ -197,7 +195,6 @@ static void test_no_op_with_port(void) {
port > 0);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
}
static void test_no_op_with_port_and_start(void) {
@@ -219,7 +216,6 @@ static void test_no_op_with_port_and_start(void) {
grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
}
static grpc_error* tcp_connect(const test_addr* remote,
@@ -247,7 +243,7 @@ static grpc_error* tcp_connect(const test_addr* remote,
return GRPC_OS_ERROR(errno, "connect");
}
gpr_log(GPR_DEBUG, "wait");
- while (g_nconnects == nconnects_before && deadline > grpc_exec_ctx_now()) {
+ while (g_nconnects == nconnects_before && deadline > ExecCtx::Get()->Now()) {
grpc_pollset_worker* worker = NULL;
grpc_error* err;
if ((err = grpc_pollset_work(g_pollset, &worker, deadline)) !=
@@ -257,7 +253,7 @@ static grpc_error* tcp_connect(const test_addr* remote,
return err;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_log(GPR_DEBUG, "wait done");
@@ -413,7 +409,6 @@ static void test_connect(size_t num_connects,
GPR_ASSERT(grpc_tcp_server_port_fd(s, 0, 0) >= 0);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
/* Weak ref lost. */
GPR_ASSERT(weak_ref.server == NULL);
@@ -489,7 +484,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(dst_addrs);
gpr_free(g_pollset);
diff --git a/test/core/iomgr/tcp_server_uv_test.cc b/test/core/iomgr/tcp_server_uv_test.cc
index 2a0ada225c..50042af37f 100644
--- a/test/core/iomgr/tcp_server_uv_test.cc
+++ b/test/core/iomgr/tcp_server_uv_test.cc
@@ -119,7 +119,6 @@ static void test_no_op(void) {
grpc_tcp_server* s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
}
static void test_no_op_with_start(void) {
@@ -129,7 +128,6 @@ static void test_no_op_with_start(void) {
LOG_TEST("test_no_op_with_start");
grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
}
static void test_no_op_with_port(void) {
@@ -149,7 +147,6 @@ static void test_no_op_with_port(void) {
port > 0);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
}
static void test_no_op_with_port_and_start(void) {
@@ -171,7 +168,6 @@ static void test_no_op_with_port_and_start(void) {
grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
}
static void connect_cb(uv_connect_t* req, int status) {
@@ -205,7 +201,7 @@ static void tcp_connect(const struct sockaddr* remote, socklen_t remote_len,
grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(deadline))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(g_mu);
}
gpr_log(GPR_DEBUG, "wait done");
@@ -277,7 +273,6 @@ static void test_connect(unsigned n) {
GPR_ASSERT(weak_ref.server != NULL);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
/* Weak ref lost. */
GPR_ASSERT(weak_ref.server == NULL);
@@ -305,7 +300,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
diff --git a/test/core/iomgr/timer_list_test.cc b/test/core/iomgr/timer_list_test.cc
index 07dfec168c..7281f55b85 100644
--- a/test/core/iomgr/timer_list_test.cc
+++ b/test/core/iomgr/timer_list_test.cc
@@ -52,7 +52,7 @@ static void add_test(void) {
grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
- grpc_millis start = grpc_exec_ctx_now();
+ grpc_millis start = ExecCtx::Get()->Now();
/* 10 ms timers. will expire in the current epoch */
for (i = 0; i < 10; i++) {
@@ -69,32 +69,32 @@ static void add_test(void) {
}
/* collect timers. Only the first batch should be ready. */
- exec_ctx->now = start + 500;
+ ExecCtx::Get()->SetNow(start + 500);
GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish();
+
for (i = 0; i < 20; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
GPR_ASSERT(cb_called[i][0] == 0);
}
- exec_ctx->now = start + 600;
+ ExecCtx::Get()->SetNow(start + 600);
GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY);
- grpc_exec_ctx_finish();
+
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
GPR_ASSERT(cb_called[i][0] == 0);
}
/* collect the rest of the timers */
- exec_ctx->now = start + 1500;
+ ExecCtx::Get()->SetNow(start + 1500);
GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish();
+
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
GPR_ASSERT(cb_called[i][0] == 0);
}
- exec_ctx->now = start + 1600;
+ ExecCtx::Get()->SetNow(start + 1600);
GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY);
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
@@ -102,7 +102,6 @@ static void add_test(void) {
}
grpc_timer_list_shutdown();
- grpc_exec_ctx_finish();
}
/* Cleaning up a list with pending timers. */
@@ -112,8 +111,7 @@ void destruction_test(void) {
gpr_log(GPR_INFO, "destruction_test");
- exec_ctx->now_is_valid = true;
- exec_ctx->now = 0;
+ ExecCtx::Get()->SetNow(0);
grpc_timer_list_init();
grpc_timer_trace.value = 1;
grpc_timer_check_trace.value = 1;
@@ -134,18 +132,18 @@ void destruction_test(void) {
grpc_timer_init(
&timers[4], 1,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)4, grpc_schedule_on_exec_ctx));
- exec_ctx->now = 2;
+ ExecCtx::Get()->SetNow(2);
GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(1 == cb_called[4][1]);
grpc_timer_cancel(&timers[0]);
grpc_timer_cancel(&timers[3]);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(1 == cb_called[0][0]);
GPR_ASSERT(1 == cb_called[3][0]);
grpc_timer_list_shutdown();
- grpc_exec_ctx_finish();
+
GPR_ASSERT(1 == cb_called[1][0]);
GPR_ASSERT(1 == cb_called[2][0]);
}
diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc
index c079dbf716..47e5cf0254 100644
--- a/test/core/iomgr/udp_server_test.cc
+++ b/test/core/iomgr/udp_server_test.cc
@@ -130,7 +130,6 @@ static void test_no_op(void) {
ExecCtx _local_exec_ctx;
grpc_udp_server* s = grpc_udp_server_create(NULL);
grpc_udp_server_destroy(s, NULL);
- grpc_exec_ctx_finish();
}
static void test_no_op_with_start(void) {
@@ -139,7 +138,6 @@ static void test_no_op_with_start(void) {
LOG_TEST("test_no_op_with_start");
grpc_udp_server_start(s, NULL, 0, NULL);
grpc_udp_server_destroy(s, NULL);
- grpc_exec_ctx_finish();
}
static void test_no_op_with_port(void) {
@@ -157,7 +155,6 @@ static void test_no_op_with_port(void) {
on_fd_orphaned));
grpc_udp_server_destroy(s, NULL);
- grpc_exec_ctx_finish();
/* The server had a single FD, which should have been orphaned. */
GPR_ASSERT(g_number_of_orphan_calls == 1);
@@ -188,7 +185,7 @@ static void test_no_op_with_port_and_socket_factory(void) {
GPR_ASSERT(socket_factory->number_of_bind_calls == 1);
grpc_udp_server_destroy(s, NULL);
- grpc_exec_ctx_finish();
+
grpc_socket_factory_unref(&socket_factory->base);
/* The server had a single FD, which should have been orphaned. */
@@ -212,7 +209,6 @@ static void test_no_op_with_port_and_start(void) {
grpc_udp_server_start(s, NULL, 0, NULL);
grpc_udp_server_destroy(s, NULL);
- grpc_exec_ctx_finish();
/* The server had a single FD, which is orphaned exactly once in *
* grpc_udp_server_destroy. */
@@ -264,12 +260,12 @@ static void test_receive(int number_of_clients) {
(socklen_t)resolved_addr.len) == 0);
GPR_ASSERT(5 == write(clifd, "hello", 5));
while (g_number_of_reads == number_of_reads_before &&
- deadline > grpc_exec_ctx_now()) {
+ deadline > ExecCtx::Get()->Now()) {
grpc_pollset_worker* worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(g_number_of_reads == number_of_reads_before + 1);
@@ -280,7 +276,6 @@ static void test_receive(int number_of_clients) {
gpr_mu_unlock(g_mu);
grpc_udp_server_destroy(s, NULL);
- grpc_exec_ctx_finish();
/* The server had a single FD, which is orphaned exactly once in *
* grpc_udp_server_destroy. */
@@ -313,7 +308,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_finish();
+
gpr_free(g_pollset);
grpc_shutdown();
return 0;
diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc
index c03ae5c584..029171c931 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -154,7 +154,6 @@ static void test_empty_md_array(void) {
GPR_ASSERT(md_array.md == NULL);
GPR_ASSERT(md_array.size == 0);
grpc_credentials_mdelem_array_destroy(&md_array);
- grpc_exec_ctx_finish();
}
static void test_add_to_empty_md_array(void) {
@@ -170,7 +169,6 @@ static void test_add_to_empty_md_array(void) {
GPR_ASSERT(grpc_mdelem_eq(md, md_array.md[0]));
GRPC_MDELEM_UNREF(md);
grpc_credentials_mdelem_array_destroy(&md_array);
- grpc_exec_ctx_finish();
}
static void test_add_abunch_to_md_array(void) {
@@ -190,7 +188,6 @@ static void test_add_abunch_to_md_array(void) {
}
GRPC_MDELEM_UNREF(md);
grpc_credentials_mdelem_array_destroy(&md_array);
- grpc_exec_ctx_finish();
}
static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
@@ -208,7 +205,6 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
0);
GRPC_MDELEM_UNREF(token_md);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish();
}
static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) {
@@ -221,7 +217,6 @@ static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) {
&response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish();
}
static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) {
@@ -233,7 +228,6 @@ static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) {
&response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish();
}
static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
@@ -249,7 +243,6 @@ static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
&response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish();
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
@@ -264,7 +257,6 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
&response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish();
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
@@ -280,7 +272,6 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
&response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish();
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
@@ -296,7 +287,6 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
&response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish();
}
typedef struct {
@@ -402,7 +392,6 @@ static void test_google_iam_creds(void) {
NULL};
run_request_metadata_test(creds, auth_md_ctx, state);
grpc_call_credentials_unref(creds);
- grpc_exec_ctx_finish();
}
static void test_access_token_creds(void) {
@@ -417,7 +406,6 @@ static void test_access_token_creds(void) {
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
run_request_metadata_test(creds, auth_md_ctx, state);
grpc_call_credentials_unref(creds);
- grpc_exec_ctx_finish();
}
static grpc_security_status check_channel_oauth2_create_security_connector(
@@ -448,7 +436,6 @@ static void test_channel_oauth2_composite_creds(void) {
channel_oauth2_creds, NULL, NULL, NULL, &new_args) ==
GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_creds);
- grpc_exec_ctx_finish();
}
static void test_oauth2_google_iam_composite_creds(void) {
@@ -484,7 +471,6 @@ static void test_oauth2_google_iam_composite_creds(void) {
GRPC_CALL_CREDENTIALS_TYPE_IAM) == 0);
run_request_metadata_test(composite_creds, auth_md_ctx, state);
grpc_call_credentials_unref(composite_creds);
- grpc_exec_ctx_finish();
}
static grpc_security_status
@@ -533,7 +519,6 @@ static void test_channel_oauth2_google_iam_composite_creds(void) {
GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_iam_creds);
- grpc_exec_ctx_finish();
}
static void validate_compute_engine_http_request(
@@ -598,7 +583,7 @@ static void test_compute_engine_creds_success(void) {
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
run_request_metadata_test(creds, auth_md_ctx, state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
@@ -606,11 +591,10 @@ static void test_compute_engine_creds_success(void) {
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
run_request_metadata_test(creds, auth_md_ctx, state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(NULL, NULL);
- grpc_exec_ctx_finish();
}
static void test_compute_engine_creds_failure(void) {
@@ -628,7 +612,6 @@ static void test_compute_engine_creds_failure(void) {
run_request_metadata_test(creds, auth_md_ctx, state);
grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(NULL, NULL);
- grpc_exec_ctx_finish();
}
static void validate_refresh_token_http_request(
@@ -689,7 +672,7 @@ static void test_refresh_token_creds_success(void) {
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_success);
run_request_metadata_test(creds, auth_md_ctx, state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
@@ -697,11 +680,10 @@ static void test_refresh_token_creds_success(void) {
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
run_request_metadata_test(creds, auth_md_ctx, state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(NULL, NULL);
- grpc_exec_ctx_finish();
}
static void test_refresh_token_creds_failure(void) {
@@ -719,7 +701,6 @@ static void test_refresh_token_creds_failure(void) {
run_request_metadata_test(creds, auth_md_ctx, state);
grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(NULL, NULL);
- grpc_exec_ctx_finish();
}
static void validate_jwt_encode_and_sign_params(
@@ -824,7 +805,7 @@ static void test_jwt_creds_success(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
run_request_metadata_test(creds, auth_md_ctx, state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
@@ -832,7 +813,7 @@ static void test_jwt_creds_success(void) {
grpc_jwt_encode_and_sign_set_override(
encode_and_sign_jwt_should_not_be_called);
run_request_metadata_test(creds, auth_md_ctx, state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Third request: Different service url so jwt_encode_and_sign should be
called again (no caching). */
@@ -841,13 +822,12 @@ static void test_jwt_creds_success(void) {
auth_md_ctx.service_url = other_test_service_url;
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
run_request_metadata_test(creds, auth_md_ctx, state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_call_credentials_unref(creds);
gpr_free(json_key_string);
gpr_free(expected_md_value);
grpc_jwt_encode_and_sign_set_override(NULL);
- grpc_exec_ctx_finish();
}
static void test_jwt_creds_signing_failure(void) {
@@ -867,7 +847,6 @@ static void test_jwt_creds_signing_failure(void) {
gpr_free(json_key_string);
grpc_call_credentials_unref(creds);
grpc_jwt_encode_and_sign_set_override(NULL);
- grpc_exec_ctx_finish();
}
static void set_google_default_creds_env_var_with_file_contents(
@@ -902,7 +881,6 @@ static void test_google_default_creds_auth_key(void) {
0);
grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
- grpc_exec_ctx_finish();
}
static void test_google_default_creds_refresh_token(void) {
@@ -920,7 +898,6 @@ static void test_google_default_creds_refresh_token(void) {
"32555999999.apps.googleusercontent.com") == 0);
grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
- grpc_exec_ctx_finish();
}
static int default_creds_gce_detection_httpcli_get_success_override(
@@ -968,7 +945,7 @@ static void test_google_default_creds_gce(void) {
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
run_request_metadata_test(creds->call_creds, auth_md_ctx, state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
/* Check that we get a cached creds if we call
grpc_google_default_credentials_create again.
@@ -984,7 +961,6 @@ static void test_google_default_creds_gce(void) {
grpc_channel_credentials_unref(&creds->base);
grpc_httpcli_set_override(NULL, NULL);
grpc_override_well_known_credentials_path_getter(NULL);
- grpc_exec_ctx_finish();
}
static int default_creds_gce_detection_httpcli_get_failure_override(
@@ -1094,7 +1070,7 @@ static void test_metadata_plugin_success(void) {
run_request_metadata_test(creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
grpc_call_credentials_unref(creds);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
}
@@ -1122,7 +1098,7 @@ static void test_metadata_plugin_failure(void) {
run_request_metadata_test(creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
grpc_call_credentials_unref(creds);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
}
@@ -1167,8 +1143,6 @@ static void test_channel_creds_duplicate_without_call_creds(void) {
grpc_channel_credentials_unref(channel_creds);
grpc_channel_credentials_unref(composite_creds);
-
- grpc_exec_ctx_finish();
}
typedef struct {
diff --git a/test/core/security/json_token_test.cc b/test/core/security/json_token_test.cc
index 7052925944..9eac2b9254 100644
--- a/test/core/security/json_token_test.cc
+++ b/test/core/security/json_token_test.cc
@@ -224,7 +224,7 @@ static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
gpr_free(b64);
*scratchpad = decoded;
grpc_slice_unref(slice);
- grpc_exec_ctx_finish();
+
return json;
}
@@ -348,8 +348,6 @@ static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
grpc_slice_unref_internal(sig);
if (key != NULL) EVP_PKEY_free(key);
if (md_ctx != NULL) EVP_MD_CTX_destroy(md_ctx);
-
- grpc_exec_ctx_finish();
}
static char* service_account_creds_jwt_encode_and_sign(
diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc
index 16fad9d45e..7485aa10b4 100644
--- a/test/core/security/jwt_verifier_test.cc
+++ b/test/core/security/jwt_verifier_test.cc
@@ -220,7 +220,6 @@ static void test_claims_success(void) {
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_OK);
grpc_jwt_claims_destroy(claims);
- grpc_exec_ctx_finish();
}
static void test_expired_claims_failure(void) {
@@ -247,7 +246,6 @@ static void test_expired_claims_failure(void) {
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_TIME_CONSTRAINT_FAILURE);
grpc_jwt_claims_destroy(claims);
- grpc_exec_ctx_finish();
}
static void test_invalid_claims_failure(void) {
@@ -256,7 +254,6 @@ static void test_invalid_claims_failure(void) {
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == NULL);
- grpc_exec_ctx_finish();
}
static void test_bad_audience_claims_failure(void) {
@@ -271,7 +268,6 @@ static void test_bad_audience_claims_failure(void) {
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://bar.com") ==
GRPC_JWT_VERIFIER_BAD_AUDIENCE);
grpc_jwt_claims_destroy(claims);
- grpc_exec_ctx_finish();
}
static void test_bad_subject_claims_failure(void) {
@@ -286,7 +282,6 @@ static void test_bad_subject_claims_failure(void) {
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_BAD_SUBJECT);
grpc_jwt_claims_destroy(claims);
- grpc_exec_ctx_finish();
}
static char* json_key_str(const char* last_part) {
@@ -371,7 +366,7 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
grpc_jwt_verifier_verify(verifier, NULL, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(verifier);
- grpc_exec_ctx_finish();
+
gpr_free(jwt);
grpc_httpcli_set_override(NULL, NULL);
}
@@ -404,7 +399,7 @@ static void test_jwt_verifier_custom_email_issuer_success(void) {
grpc_jwt_verifier_verify(verifier, NULL, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(verifier);
- grpc_exec_ctx_finish();
+
gpr_free(jwt);
grpc_httpcli_set_override(NULL, NULL);
}
@@ -451,7 +446,7 @@ static void test_jwt_verifier_url_issuer_success(void) {
grpc_jwt_verifier_verify(verifier, NULL, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(verifier);
- grpc_exec_ctx_finish();
+
gpr_free(jwt);
grpc_httpcli_set_override(NULL, NULL);
}
@@ -491,7 +486,7 @@ static void test_jwt_verifier_url_issuer_bad_config(void) {
on_verification_key_retrieval_error,
(void*)expected_user_data);
grpc_jwt_verifier_destroy(verifier);
- grpc_exec_ctx_finish();
+
gpr_free(jwt);
grpc_httpcli_set_override(NULL, NULL);
}
@@ -514,7 +509,7 @@ static void test_jwt_verifier_bad_json_key(void) {
on_verification_key_retrieval_error,
(void*)expected_user_data);
grpc_jwt_verifier_destroy(verifier);
- grpc_exec_ctx_finish();
+
gpr_free(jwt);
grpc_httpcli_set_override(NULL, NULL);
}
@@ -528,7 +523,6 @@ static void corrupt_jwt_sig(char* jwt) {
{
ExecCtx _local_exec_ctx;
sig = grpc_base64_decode(last_dot + 1, 1);
- grpc_exec_ctx_finish();
}
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
sig_bytes = GRPC_SLICE_START_PTR(sig);
@@ -568,7 +562,7 @@ static void test_jwt_verifier_bad_signature(void) {
(void*)expected_user_data);
gpr_free(jwt);
grpc_jwt_verifier_destroy(verifier);
- grpc_exec_ctx_finish();
+
grpc_httpcli_set_override(NULL, NULL);
}
@@ -597,7 +591,7 @@ static void test_jwt_verifier_bad_format(void) {
on_verification_bad_format,
(void*)expected_user_data);
grpc_jwt_verifier_destroy(verifier);
- grpc_exec_ctx_finish();
+
grpc_httpcli_set_override(NULL, NULL);
}
diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc
index 6104c7e9dd..f4a52aaba0 100644
--- a/test/core/security/oauth2_utils.cc
+++ b/test/core/security/oauth2_utils.cc
@@ -92,7 +92,7 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
on_oauth2_response(&request, error);
GRPC_ERROR_UNREF(error);
}
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(request.mu);
while (!request.is_done) {
@@ -108,7 +108,7 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
grpc_pollset_shutdown(grpc_polling_entity_pollset(&request.pops),
&do_nothing_closure);
- grpc_exec_ctx_finish();
+
gpr_free(grpc_polling_entity_pollset(&request.pops));
return request.token;
}
diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc
index 6ea51658e1..6153e8a9cb 100644
--- a/test/core/security/print_google_default_creds_token.cc
+++ b/test/core/security/print_google_default_creds_token.cc
@@ -111,13 +111,11 @@ int main(int argc, char** argv) {
GRPC_MILLIS_INF_FUTURE)))
sync.is_done = true;
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(sync.mu);
}
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_finish();
-
grpc_channel_credentials_release(creds);
gpr_free(grpc_polling_entity_pollset(&sync.pops));
diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc
index a72329d504..a49bf1a0b4 100644
--- a/test/core/security/secure_endpoint_test.cc
+++ b/test/core/security/secure_endpoint_test.cc
@@ -115,7 +115,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
f.server_ep = grpc_secure_endpoint_create(fake_write_protector,
fake_write_zero_copy_protector,
tcp.server, NULL, 0);
- grpc_exec_ctx_finish();
+
return f;
}
@@ -178,7 +178,7 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
grpc_slice_buffer_init(&incoming);
GRPC_CLOSURE_INIT(&done_closure, inc_call_ctr, &n, grpc_schedule_on_exec_ctx);
grpc_endpoint_read(f.client_ep, &incoming, &done_closure);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(n == 1);
GPR_ASSERT(incoming.count == 1);
GPR_ASSERT(grpc_slice_eq(s, incoming.slices[0]));
@@ -189,7 +189,7 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
f.server_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
grpc_endpoint_destroy(f.client_ep);
grpc_endpoint_destroy(f.server_ep);
- grpc_exec_ctx_finish();
+
grpc_slice_unref_internal(s);
grpc_slice_buffer_destroy_internal(&incoming);
@@ -215,7 +215,7 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(g_pollset, &destroyed);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc
index 3ee7738ea8..84a42546c6 100644
--- a/test/core/security/ssl_server_fuzzer.cc
+++ b/test/core/security/ssl_server_fuzzer.cc
@@ -83,7 +83,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_security_status status =
grpc_server_credentials_create_security_connector(creds, &sc);
GPR_ASSERT(status == GRPC_SECURITY_OK);
- grpc_millis deadline = GPR_MS_PER_SEC + grpc_exec_ctx_now();
+ grpc_millis deadline = GPR_MS_PER_SEC + ExecCtx::Get()->Now();
struct handshake_state state;
state.done_callback_called = false;
@@ -92,7 +92,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_handshake_manager_do_handshake(
handshake_mgr, mock_endpoint, NULL /* channel_args */, deadline,
NULL /* acceptor */, on_handshake_done, &state);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
// If the given string happens to be part of the correct client hello, the
// server will wait for more data. Explicitly fail the server by shutting down
@@ -100,7 +100,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (!state.done_callback_called) {
grpc_endpoint_shutdown(
mock_endpoint, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Explicit close"));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
GPR_ASSERT(state.done_callback_called);
@@ -111,7 +111,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_slice_unref(cert_slice);
grpc_slice_unref(key_slice);
grpc_slice_unref(ca_slice);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_shutdown();
if (leak_check) {
diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc
index fce1e9d8de..f3e8966625 100644
--- a/test/core/security/verify_jwt.cc
+++ b/test/core/security/verify_jwt.cc
@@ -106,7 +106,7 @@ int main(int argc, char** argv) {
grpc_pollset_work(sync.pollset, &worker, GRPC_MILLIS_INF_FUTURE)))
sync.is_done = true;
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(sync.mu);
}
gpr_mu_unlock(sync.mu);
@@ -114,7 +114,7 @@ int main(int argc, char** argv) {
gpr_free(sync.pollset);
grpc_jwt_verifier_destroy(verifier);
- grpc_exec_ctx_finish();
+
gpr_cmdline_destroy(cl);
grpc_shutdown();
return !sync.success;
diff --git a/test/core/slice/b64_test.cc b/test/core/slice/b64_test.cc
index 3f1de9bc12..5ed9910740 100644
--- a/test/core/slice/b64_test.cc
+++ b/test/core/slice/b64_test.cc
@@ -51,7 +51,7 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) {
GRPC_SLICE_LENGTH(hello_slice)) == 0);
grpc_slice_unref_internal(hello_slice);
- grpc_exec_ctx_finish();
+
gpr_free(hello_b64);
}
@@ -72,7 +72,6 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
sizeof(orig) - i));
grpc_slice_unref_internal(orig_decoded);
gpr_free(b64);
- grpc_exec_ctx_finish();
}
}
@@ -128,7 +127,6 @@ static void test_url_safe_unsafe_mismatch_failure(void) {
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
grpc_slice_unref_internal(orig_decoded);
- grpc_exec_ctx_finish();
}
static void test_rfc4648_test_vectors(void) {
@@ -199,7 +197,6 @@ static void test_unpadded_decode(void) {
decoded = grpc_base64_decode("", 0);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded));
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/slice/slice_hash_table_test.cc b/test/core/slice/slice_hash_table_test.cc
index b5b9c1bb73..89fc33a7bf 100644
--- a/test/core/slice/slice_hash_table_test.cc
+++ b/test/core/slice/slice_hash_table_test.cc
@@ -121,7 +121,6 @@ static void test_slice_hash_table() {
// Clean up.
ExecCtx _local_exec_ctx;
grpc_slice_hash_table_unref(table);
- grpc_exec_ctx_finish();
}
static int value_cmp_fn(void* a, void* b) {
@@ -150,7 +149,6 @@ static void test_slice_hash_table_eq() {
ExecCtx _local_exec_ctx;
grpc_slice_hash_table_unref(table_a);
grpc_slice_hash_table_unref(table_b);
- grpc_exec_ctx_finish();
}
static void test_slice_hash_table_not_eq() {
@@ -229,7 +227,6 @@ static void test_slice_hash_table_not_eq() {
grpc_slice_hash_table_unref(table_f);
grpc_slice_hash_table_unref(table_g);
grpc_slice_hash_table_unref(table_h);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/surface/byte_buffer_reader_test.cc b/test/core/surface/byte_buffer_reader_test.cc
index 0ac4018a9e..1f3a83efe6 100644
--- a/test/core/surface/byte_buffer_reader_test.cc
+++ b/test/core/surface/byte_buffer_reader_test.cc
@@ -134,7 +134,6 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
{
ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out));
- grpc_exec_ctx_finish();
}
buffer = grpc_raw_compressed_byte_buffer_create(sliceb_out.slices,
diff --git a/test/core/surface/channel_create_test.cc b/test/core/surface/channel_create_test.cc
index 516a55275a..ece06e4968 100644
--- a/test/core/surface/channel_create_test.cc
+++ b/test/core/surface/channel_create_test.cc
@@ -39,7 +39,6 @@ void test_unknown_scheme_target(void) {
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx_finish();
grpc_channel_destroy(chan);
}
diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc
index f014738f4c..39aedeba02 100644
--- a/test/core/surface/completion_queue_test.cc
+++ b/test/core/surface/completion_queue_test.cc
@@ -151,7 +151,6 @@ static void test_cq_end_op(void) {
GPR_ASSERT(ev.success);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish();
}
}
@@ -193,7 +192,6 @@ static void test_cq_tls_cache_full(void) {
GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish();
}
}
@@ -221,7 +219,6 @@ static void test_cq_tls_cache_empty(void) {
GPR_ASSERT(
grpc_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 0);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish();
}
}
@@ -322,7 +319,6 @@ static void test_pluck(void) {
}
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish();
}
}
diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc
index 43e90029bc..6625e7e09f 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -116,7 +116,6 @@ static void test_too_many_plucks(void) {
}
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish();
}
#define TEST_THREAD_EVENTS 10000
@@ -165,12 +164,10 @@ static void producer_thread(void* arg) {
static_cast<grpc_cq_completion*>(
gpr_malloc(sizeof(grpc_cq_completion))));
opt->events_triggered++;
- grpc_exec_ctx_finish();
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
- grpc_exec_ctx_finish();
}
static void consumer_thread(void* arg) {
diff --git a/test/core/surface/concurrent_connectivity_test.cc b/test/core/surface/concurrent_connectivity_test.cc
index 62fb58dcbc..b3999b481f 100644
--- a/test/core/surface/concurrent_connectivity_test.cc
+++ b/test/core/surface/concurrent_connectivity_test.cc
@@ -134,7 +134,7 @@ void bad_server_thread(void* vargs) {
gpr_mu_lock(args->mu);
while (gpr_atm_acq_load(&args->stop) == 0) {
- grpc_millis deadline = grpc_exec_ctx_now() + 100;
+ grpc_millis deadline = ExecCtx::Get()->Now() + 100;
grpc_pollset_worker* worker = NULL;
if (!GRPC_LOG_IF_ERROR(
@@ -143,15 +143,13 @@ void bad_server_thread(void* vargs) {
gpr_atm_rel_store(&args->stop, 1);
}
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish();
+
gpr_mu_lock(args->mu);
}
gpr_mu_unlock(args->mu);
grpc_tcp_server_unref(s);
- grpc_exec_ctx_finish();
-
gpr_free(args->addr);
}
@@ -228,7 +226,6 @@ int run_concurrent_connectivity_test() {
grpc_pollset_shutdown(args.pollset,
GRPC_CLOSURE_CREATE(done_pollset_shutdown, args.pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish();
grpc_shutdown();
return 0;
diff --git a/test/core/surface/lame_client_test.cc b/test/core/surface/lame_client_test.cc
index 7104d2e30a..dd14a03577 100644
--- a/test/core/surface/lame_client_test.cc
+++ b/test/core/surface/lame_client_test.cc
@@ -54,13 +54,11 @@ void test_transport_op(grpc_channel* channel) {
op->connectivity_state = &state;
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
elem->filter->start_transport_op(elem, op);
- grpc_exec_ctx_finish();
GRPC_CLOSURE_INIT(&transport_op_cb, do_nothing, NULL,
grpc_schedule_on_exec_ctx);
op = grpc_make_transport_op(&transport_op_cb);
elem->filter->start_transport_op(elem, op);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc
index e7cde7e39b..bf51dac6dd 100644
--- a/test/core/surface/num_external_connectivity_watchers_test.cc
+++ b/test/core/surface/num_external_connectivity_watchers_test.cc
@@ -180,7 +180,6 @@ static grpc_channel* secure_test_create_channel(const char* addr) {
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(new_client_args);
- grpc_exec_ctx_finish();
}
grpc_channel_credentials_release(ssl_creds);
return channel;
diff --git a/test/core/surface/secure_channel_create_test.cc b/test/core/surface/secure_channel_create_test.cc
index 9a4ac1f0bd..dd9f907652 100644
--- a/test/core/surface/secure_channel_create_test.cc
+++ b/test/core/surface/secure_channel_create_test.cc
@@ -40,7 +40,6 @@ void test_unknown_scheme_target(void) {
ExecCtx _local_exec_ctx;
GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
grpc_channel_credentials_unref(creds);
- grpc_exec_ctx_finish();
}
void test_security_connector_already_in_arg(void) {
@@ -57,7 +56,6 @@ void test_security_connector_already_in_arg(void) {
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
ExecCtx _local_exec_ctx;
GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
- grpc_exec_ctx_finish();
}
void test_null_creds(void) {
@@ -67,7 +65,6 @@ void test_null_creds(void) {
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
ExecCtx _local_exec_ctx;
GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc
index f88124e4ae..aae418cedb 100644
--- a/test/core/surface/sequential_connectivity_test.cc
+++ b/test/core/surface/sequential_connectivity_test.cc
@@ -158,7 +158,6 @@ static grpc_channel* secure_test_create_channel(const char* addr) {
{
ExecCtx _local_exec_ctx;
grpc_channel_args_destroy(new_client_args);
- grpc_exec_ctx_finish();
}
grpc_channel_credentials_release(ssl_creds);
return channel;
diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc
index ca29b82616..4d41ece875 100644
--- a/test/core/transport/bdp_estimator_test.cc
+++ b/test/core/transport/bdp_estimator_test.cc
@@ -66,9 +66,8 @@ void AddSamples(BdpEstimator* estimator, int64_t* samples, size_t n) {
}
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_millis(1, GPR_TIMESPAN)));
- grpc_exec_ctx_invalidate_now();
+ ExecCtx::Get()->InvalidateNow();
estimator->CompletePing();
- grpc_exec_ctx_finish();
}
void AddSample(BdpEstimator* estimator, int64_t sample) {
diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc
index af6abaeeed..12a933f332 100644
--- a/test/core/transport/byte_stream_test.cc
+++ b/test/core/transport/byte_stream_test.cc
@@ -66,7 +66,6 @@ static void test_slice_buffer_stream_basic(void) {
// Clean up.
grpc_byte_stream_destroy(&stream.base);
grpc_slice_buffer_destroy_internal(&buffer);
- grpc_exec_ctx_finish();
}
static void test_slice_buffer_stream_shutdown(void) {
@@ -109,7 +108,6 @@ static void test_slice_buffer_stream_shutdown(void) {
// Clean up.
grpc_byte_stream_destroy(&stream.base);
grpc_slice_buffer_destroy_internal(&buffer);
- grpc_exec_ctx_finish();
}
//
@@ -153,7 +151,6 @@ static void test_caching_byte_stream_basic(void) {
grpc_byte_stream_destroy(&stream.base);
grpc_byte_stream_cache_destroy(&cache);
grpc_slice_buffer_destroy_internal(&buffer);
- grpc_exec_ctx_finish();
}
static void test_caching_byte_stream_reset(void) {
@@ -200,7 +197,6 @@ static void test_caching_byte_stream_reset(void) {
grpc_byte_stream_destroy(&stream.base);
grpc_byte_stream_cache_destroy(&cache);
grpc_slice_buffer_destroy_internal(&buffer);
- grpc_exec_ctx_finish();
}
static void test_caching_byte_stream_shared_cache(void) {
@@ -254,7 +250,6 @@ static void test_caching_byte_stream_shared_cache(void) {
grpc_byte_stream_destroy(&stream2.base);
grpc_byte_stream_cache_destroy(&cache);
grpc_slice_buffer_destroy_internal(&buffer);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/transport/chttp2/bin_decoder_test.cc b/test/core/transport/chttp2/bin_decoder_test.cc
index 663ccf189b..3d463c40a5 100644
--- a/test/core/transport/chttp2/bin_decoder_test.cc
+++ b/test/core/transport/chttp2/bin_decoder_test.cc
@@ -129,7 +129,5 @@ int main(int argc, char** argv) {
EXPECT_SLICE_EQ("", base64_decode_with_length("Zm:v", 3));
EXPECT_SLICE_EQ("", base64_decode_with_length("Zm=v", 3));
- grpc_exec_ctx_finish();
-
return all_ok ? 0 : 1;
}
diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc
index e1bfcc5b37..fe4538339e 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.cc
+++ b/test/core/transport/chttp2/hpack_encoder_test.cc
@@ -261,7 +261,6 @@ static void run_test(void (*test)(), const char* name) {
grpc_chttp2_hpack_compressor_init(&g_compressor);
test();
grpc_chttp2_hpack_compressor_destroy(&g_compressor);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
index d2199ca706..feb27fc0ff 100644
--- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
+++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
@@ -43,7 +43,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
GRPC_ERROR_UNREF(grpc_chttp2_hpack_parser_parse(
&parser, grpc_slice_from_static_buffer(data, size)));
grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc
index 0a3cbf84ad..69a13108f9 100644
--- a/test/core/transport/chttp2/hpack_parser_test.cc
+++ b/test/core/transport/chttp2/hpack_parser_test.cc
@@ -65,7 +65,6 @@ static void test_vector(grpc_chttp2_hpack_parser* parser,
ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_chttp2_hpack_parser_parse(parser, slices[i]) ==
GRPC_ERROR_NONE);
- grpc_exec_ctx_finish();
}
for (i = 0; i < nslices; i++) {
@@ -204,8 +203,6 @@ static void test_vectors(grpc_slice_split_mode mode) {
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
grpc_chttp2_hpack_parser_destroy(&parser);
-
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/transport/chttp2/hpack_table_test.cc b/test/core/transport/chttp2/hpack_table_test.cc
index 68682f1991..fd5604d857 100644
--- a/test/core/transport/chttp2/hpack_table_test.cc
+++ b/test/core/transport/chttp2/hpack_table_test.cc
@@ -113,7 +113,6 @@ static void test_static_lookup(void) {
assert_index(&tbl, 61, "www-authenticate", "");
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_exec_ctx_finish();
}
static void test_many_additions(void) {
@@ -148,7 +147,6 @@ static void test_many_additions(void) {
}
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_exec_ctx_finish();
}
static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl* tbl,
@@ -159,7 +157,7 @@ static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl* tbl,
grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
grpc_chttp2_hptbl_find_result r = grpc_chttp2_hptbl_find(tbl, md);
GRPC_MDELEM_UNREF(md);
- grpc_exec_ctx_finish();
+
return r;
}
@@ -266,7 +264,6 @@ static void test_find(void) {
GPR_ASSERT(r.has_value == 0);
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {
diff --git a/test/core/transport/connectivity_state_test.cc b/test/core/transport/connectivity_state_test.cc
index 92bf1ba903..8ddd8bb2df 100644
--- a/test/core/transport/connectivity_state_test.cc
+++ b/test/core/transport/connectivity_state_test.cc
@@ -66,7 +66,6 @@ static void test_check(void) {
GPR_ASSERT(grpc_connectivity_state_check(&tracker) == GRPC_CHANNEL_IDLE);
GPR_ASSERT(error == GRPC_ERROR_NONE);
grpc_connectivity_state_destroy(&tracker);
- grpc_exec_ctx_finish();
}
static void test_subscribe_then_unsubscribe(void) {
@@ -80,16 +79,15 @@ static void test_subscribe_then_unsubscribe(void) {
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&tracker, &state,
closure));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
grpc_connectivity_state_notify_on_state_change(&tracker, NULL, closure);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 1);
grpc_connectivity_state_destroy(&tracker);
- grpc_exec_ctx_finish();
}
static void test_subscribe_then_destroy(void) {
@@ -103,11 +101,11 @@ static void test_subscribe_then_destroy(void) {
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&tracker, &state,
closure));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
grpc_connectivity_state_destroy(&tracker);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}
@@ -123,11 +121,11 @@ static void test_subscribe_with_failure_then_destroy(void) {
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_SHUTDOWN, "xxx");
GPR_ASSERT(0 == grpc_connectivity_state_notify_on_state_change(
&tracker, &state, closure));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 0);
grpc_connectivity_state_destroy(&tracker);
- grpc_exec_ctx_finish();
+
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}
diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc
index 4bc5672958..3d7034e4ce 100644
--- a/test/core/transport/metadata_test.cc
+++ b/test/core/transport/metadata_test.cc
@@ -80,7 +80,7 @@ static void test_create_metadata(bool intern_keys, bool intern_values) {
GRPC_MDELEM_UNREF(m1);
GRPC_MDELEM_UNREF(m2);
GRPC_MDELEM_UNREF(m3);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
}
@@ -103,7 +103,7 @@ static void test_create_many_ephemeral_metadata(bool intern_keys,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_copied_string(buffer), intern_values)));
}
- grpc_exec_ctx_finish();
+
grpc_shutdown();
}
@@ -138,7 +138,7 @@ static void test_create_many_persistant_metadata(void) {
for (i = 0; i < MANY; i++) {
GRPC_MDELEM_UNREF(created[i]);
}
- grpc_exec_ctx_finish();
+
grpc_shutdown();
gpr_free(created);
@@ -169,7 +169,7 @@ static void test_spin_creating_the_same_thing(bool intern_keys,
GPR_ASSERT(a.payload == b.payload);
GPR_ASSERT(a.payload == c.payload);
}
- grpc_exec_ctx_finish();
+
grpc_shutdown();
}
@@ -209,7 +209,7 @@ static void test_identity_laws(bool intern_keys, bool intern_values) {
GRPC_MDELEM_UNREF(a);
GRPC_MDELEM_UNREF(b);
GRPC_MDELEM_UNREF(c);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
}
@@ -259,7 +259,6 @@ static void test_things_stick_around(void) {
}
}
- grpc_exec_ctx_finish();
grpc_shutdown();
gpr_free(strs);
gpr_free(shuf);
@@ -284,7 +283,7 @@ static void test_user_data_works(void) {
grpc_mdelem_set_user_data(md, gpr_free, ud2);
GPR_ASSERT(grpc_mdelem_get_user_data(md, gpr_free) == ud1);
GRPC_MDELEM_UNREF(md);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
}
@@ -340,7 +339,6 @@ static void test_mdelem_sizes_in_hpack(bool intern_key, bool intern_value) {
intern_value);
}
- grpc_exec_ctx_finish();
grpc_shutdown();
}
@@ -366,7 +364,6 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
GRPC_MDELEM_UNREF(q);
}
- grpc_exec_ctx_finish();
grpc_shutdown();
}
diff --git a/test/core/transport/status_conversion_test.cc b/test/core/transport/status_conversion_test.cc
index 44e961310a..16ecd076a3 100644
--- a/test/core/transport/status_conversion_test.cc
+++ b/test/core/transport/status_conversion_test.cc
@@ -26,7 +26,7 @@
do { \
ExecCtx _local_exec_ctx; \
GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b)); \
- grpc_exec_ctx_finish(); \
+ \
} while (0)
#define GRPC_STATUS_TO_HTTP2_STATUS(a, b) \
GPR_ASSERT(grpc_status_to_http2_status(a) == (b))
diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc
index 2cabd560ee..4e68ee3744 100644
--- a/test/core/util/port_server_client.cc
+++ b/test/core/util/port_server_client.cc
@@ -85,19 +85,19 @@ void grpc_free_port_using_server(int port) {
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/free");
grpc_httpcli_get(&context, &pr.pops, resource_quota, &req,
- grpc_exec_ctx_now() + 30 * GPR_MS_PER_SEC,
+ ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(freed_port_from_server, &pr,
grpc_schedule_on_exec_ctx),
&rsp);
grpc_resource_quota_unref_internal(resource_quota);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);
while (!pr.done) {
grpc_pollset_worker* worker = NULL;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(grpc_polling_entity_pollset(&pr.pops), &worker,
- grpc_exec_ctx_now() + GPR_MS_PER_SEC))) {
+ ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
pr.done = 1;
}
}
@@ -106,7 +106,7 @@ void grpc_free_port_using_server(int port) {
grpc_httpcli_context_destroy(&context);
grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
- grpc_exec_ctx_finish();
+
gpr_free(path);
grpc_http_response_destroy(&rsp);
@@ -167,7 +167,7 @@ static void got_port_from_server(void* arg, grpc_error* error) {
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/pick_retry");
grpc_httpcli_get(pr->ctx, &pr->pops, resource_quota, &req,
- grpc_exec_ctx_now() + 30 * GPR_MS_PER_SEC,
+ ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(got_port_from_server, pr,
grpc_schedule_on_exec_ctx),
&pr->response);
@@ -217,18 +217,18 @@ int grpc_pick_port_using_server(void) {
grpc_resource_quota_create("port_server_client/pick");
grpc_httpcli_get(
&context, &pr.pops, resource_quota, &req,
- grpc_exec_ctx_now() + 30 * GPR_MS_PER_SEC,
+ ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(got_port_from_server, &pr, grpc_schedule_on_exec_ctx),
&pr.response);
grpc_resource_quota_unref_internal(resource_quota);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);
while (pr.port == -1) {
grpc_pollset_worker* worker = NULL;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(grpc_polling_entity_pollset(&pr.pops), &worker,
- grpc_exec_ctx_now() + GPR_MS_PER_SEC))) {
+ ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
pr.port = 0;
}
}
@@ -238,7 +238,7 @@ int grpc_pick_port_using_server(void) {
grpc_httpcli_context_destroy(&context);
grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
- grpc_exec_ctx_finish();
+
grpc_shutdown();
return pr.port;
diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc
index 79178a7cbd..7e17ff1f53 100644
--- a/test/core/util/test_tcp_server.cc
+++ b/test/core/util/test_tcp_server.cc
@@ -72,8 +72,6 @@ void test_tcp_server_start(test_tcp_server* server, int port) {
grpc_tcp_server_start(server->tcp_server, &server->pollset, 1,
server->on_connect, server->cb_data);
gpr_log(GPR_INFO, "test tcp server listening on 0.0.0.0:%d", port);
-
- grpc_exec_ctx_finish();
}
void test_tcp_server_poll(test_tcp_server* server, int seconds) {
@@ -85,7 +83,6 @@ void test_tcp_server_poll(test_tcp_server* server, int seconds) {
GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(server->pollset, &worker, deadline));
gpr_mu_unlock(server->mu);
- grpc_exec_ctx_finish();
}
static void do_nothing(void* arg, grpc_error* error) {}
@@ -109,7 +106,7 @@ void test_tcp_server_destroy(test_tcp_server* server) {
grpc_pollset_shutdown(server->pollset,
GRPC_CLOSURE_CREATE(finish_pollset, server->pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish();
+
gpr_free(server->pollset);
grpc_shutdown();
}
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc
index df2ed0ecd0..4cf39eab48 100644
--- a/test/cpp/end2end/client_lb_end2end_test.cc
+++ b/test/cpp/end2end/client_lb_end2end_test.cc
@@ -133,7 +133,6 @@ class ClientLbEnd2endTest : public ::testing::Test {
fake_result);
grpc_channel_args_destroy(fake_result);
grpc_lb_addresses_destroy(addresses);
- grpc_exec_ctx_finish();
}
void ResetStub(const grpc::string& lb_policy_name = "") {
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc
index 62d7094d4c..962d5a7e68 100644
--- a/test/cpp/end2end/grpclb_end2end_test.cc
+++ b/test/cpp/end2end/grpclb_end2end_test.cc
@@ -470,7 +470,6 @@ class GrpclbEnd2endTest : public ::testing::Test {
grpc_fake_resolver_response_generator_set_response(response_generator_,
&fake_result);
grpc_lb_addresses_destroy(addresses);
- grpc_exec_ctx_finish();
}
const std::vector<int> GetBackendPorts(const size_t start_index = 0) const {
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index c2c6c0b337..6f6dd3c4df 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -603,7 +603,6 @@ static void setup_client(const server_fixture* lb_server,
grpc_channel_credentials_unref(fake_creds);
grpc_channel_args_destroy(args);
grpc_fake_resolver_response_generator_unref(response_generator);
- grpc_exec_ctx_finish();
}
static void teardown_client(client_fixture* cf) {
diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc
index eac1c753c7..47b984bc28 100644
--- a/test/cpp/microbenchmarks/bm_call_create.cc
+++ b/test/cpp/microbenchmarks/bm_call_create.cc
@@ -534,7 +534,7 @@ static void BM_IsolatedFilter(benchmark::State& state) {
? &dummy_transport::dummy_transport
: nullptr,
"CHANNEL", channel_stack)));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_call_stack* call_stack =
static_cast<grpc_call_stack*>(gpr_zalloc(channel_stack->call_stack_size));
grpc_millis deadline = GRPC_MILLIS_INF_FUTURE;
@@ -558,7 +558,7 @@ static void BM_IsolatedFilter(benchmark::State& state) {
typename TestOp::Op op(&test_op_data, call_stack);
grpc_call_stack_destroy(call_stack, &final_info, NULL);
op.Finish();
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
// recreate arena every 64k iterations to avoid oom
if (0 == (state.iterations() & 0xffff)) {
gpr_arena_destroy(call_args.arena);
@@ -567,7 +567,7 @@ static void BM_IsolatedFilter(benchmark::State& state) {
}
gpr_arena_destroy(call_args.arena);
grpc_channel_stack_destroy(channel_stack);
- grpc_exec_ctx_finish();
+
gpr_free(channel_stack);
gpr_free(call_stack);
@@ -693,7 +693,6 @@ class IsolatedCallFixture : public TrackCounters {
{
ExecCtx _local_exec_ctx;
channel_ = grpc_channel_create_with_builder(builder, GRPC_CLIENT_CHANNEL);
- grpc_exec_ctx_finish();
}
cq_ = grpc_completion_queue_create_for_next(NULL);
}
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index d6fb3cd369..f822f095a7 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -55,9 +55,9 @@ static void BM_HpackEncoderInitDestroy(benchmark::State& state) {
while (state.KeepRunning()) {
grpc_chttp2_hpack_compressor_init(&c);
grpc_chttp2_hpack_compressor_destroy(&c);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_HpackEncoderInitDestroy);
@@ -65,7 +65,7 @@ BENCHMARK(BM_HpackEncoderInitDestroy);
static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
TrackCounters track_counters;
ExecCtx _local_exec_ctx;
- grpc_millis saved_now = grpc_exec_ctx_now();
+ grpc_millis saved_now = ExecCtx::Get()->Now();
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
@@ -87,12 +87,11 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
};
grpc_chttp2_encode_header(&c, NULL, 0, &b, &hopt, &outbuf);
grpc_slice_buffer_reset_and_unref_internal(&outbuf);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
grpc_metadata_batch_destroy(&b);
grpc_chttp2_hpack_compressor_destroy(&c);
grpc_slice_buffer_destroy_internal(&outbuf);
- grpc_exec_ctx_finish();
std::ostringstream label;
label << "framing_bytes/iter:"
@@ -145,12 +144,11 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
}
}
grpc_slice_buffer_reset_and_unref_internal(&outbuf);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
grpc_metadata_batch_destroy(&b);
grpc_chttp2_hpack_compressor_destroy(&c);
grpc_slice_buffer_destroy_internal(&outbuf);
- grpc_exec_ctx_finish();
std::ostringstream label;
label << "framing_bytes/iter:"
@@ -432,9 +430,9 @@ static void BM_HpackParserInitDestroy(benchmark::State& state) {
while (state.KeepRunning()) {
grpc_chttp2_hpack_parser_init(&p);
grpc_chttp2_hpack_parser_destroy(&p);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_HpackParserInitDestroy);
@@ -460,12 +458,12 @@ static void BM_HpackParserParseHeader(benchmark::State& state) {
for (auto slice : benchmark_slices) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
for (auto slice : init_slices) grpc_slice_unref(slice);
for (auto slice : benchmark_slices) grpc_slice_unref(slice);
grpc_chttp2_hpack_parser_destroy(&p);
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
index 3a3547141d..f6e4c2bcc4 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
@@ -136,12 +136,9 @@ class Fixture {
FlushExecCtx();
}
- void FlushExecCtx() { grpc_exec_ctx_flush(); }
+ void FlushExecCtx() { ExecCtx::Get()->Flush(); }
- ~Fixture() {
- grpc_transport_destroy(t_);
- grpc_exec_ctx_finish();
- }
+ ~Fixture() { grpc_transport_destroy(t_); }
grpc_chttp2_transport* chttp2_transport() {
return reinterpret_cast<grpc_chttp2_transport*>(t_);
@@ -152,7 +149,6 @@ class Fixture {
private:
DummyEndpoint* ep_;
- ExecCtx _local_exec_ctx;
grpc_transport* t_;
};
@@ -261,6 +257,7 @@ class Stream {
static void BM_StreamCreateDestroy(benchmark::State& state) {
TrackCounters track_counters;
+ ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
grpc_transport_stream_op_batch op;
@@ -306,6 +303,7 @@ class RepresentativeClientInitialMetadata {
template <class Metadata>
static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
TrackCounters track_counters;
+ ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
grpc_transport_stream_op_batch op;
@@ -356,6 +354,7 @@ BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy,
static void BM_TransportEmptyOp(benchmark::State& state) {
TrackCounters track_counters;
+ ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
s.Init(state);
@@ -388,6 +387,7 @@ std::vector<std::unique_ptr<gpr_event>> done_events;
static void BM_TransportStreamSend(benchmark::State& state) {
TrackCounters track_counters;
+ ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
auto s = std::unique_ptr<Stream>(new Stream(&f));
s->Init(state);
@@ -517,6 +517,7 @@ static grpc_slice CreateIncomingDataSlice(size_t length, size_t frame_size) {
static void BM_TransportStreamRecv(benchmark::State& state) {
TrackCounters track_counters;
+ ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
s.Init(state);
diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc
index 0e25c3d235..ce8a054515 100644
--- a/test/cpp/microbenchmarks/bm_closure.cc
+++ b/test/cpp/microbenchmarks/bm_closure.cc
@@ -35,7 +35,6 @@ static void BM_NoOpExecCtx(benchmark::State& state) {
TrackCounters track_counters;
while (state.KeepRunning()) {
ExecCtx _local_exec_ctx;
- grpc_exec_ctx_finish();
}
track_counters.Finish(state);
}
@@ -45,9 +44,9 @@ static void BM_WellFlushed(benchmark::State& state) {
TrackCounters track_counters;
ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_WellFlushed);
@@ -75,7 +74,7 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) {
&c, DoNothing, NULL, grpc_combiner_scheduler(combiner)));
}
GRPC_COMBINER_UNREF(combiner, "finished");
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureInitAgainstCombiner);
@@ -87,9 +86,9 @@ static void BM_ClosureRunOnExecCtx(benchmark::State& state) {
ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
GRPC_CLOSURE_RUN(&c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureRunOnExecCtx);
@@ -102,7 +101,7 @@ static void BM_ClosureCreateAndRun(benchmark::State& state) {
GRPC_CLOSURE_CREATE(DoNothing, NULL, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureCreateAndRun);
@@ -116,7 +115,7 @@ static void BM_ClosureInitAndRun(benchmark::State& state) {
GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureInitAndRun);
@@ -128,9 +127,9 @@ static void BM_ClosureSchedOnExecCtx(benchmark::State& state) {
ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSchedOnExecCtx);
@@ -145,9 +144,9 @@ static void BM_ClosureSched2OnExecCtx(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnExecCtx);
@@ -165,9 +164,9 @@ static void BM_ClosureSched3OnExecCtx(benchmark::State& state) {
GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched3OnExecCtx);
@@ -183,7 +182,7 @@ static void BM_AcquireMutex(benchmark::State& state) {
DoNothing(NULL, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_AcquireMutex);
@@ -202,7 +201,7 @@ static void BM_TryAcquireMutex(benchmark::State& state) {
abort();
}
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_TryAcquireMutex);
@@ -217,7 +216,7 @@ static void BM_AcquireSpinlock(benchmark::State& state) {
DoNothing(NULL, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_AcquireSpinlock);
@@ -235,7 +234,7 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) {
abort();
}
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_TryAcquireSpinlock);
@@ -248,10 +247,10 @@ static void BM_ClosureSchedOnCombiner(benchmark::State& state) {
ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
GRPC_COMBINER_UNREF(combiner, "finished");
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSchedOnCombiner);
@@ -267,10 +266,10 @@ static void BM_ClosureSched2OnCombiner(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
GRPC_COMBINER_UNREF(combiner, "finished");
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnCombiner);
@@ -289,10 +288,10 @@ static void BM_ClosureSched3OnCombiner(benchmark::State& state) {
GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
GRPC_COMBINER_UNREF(combiner, "finished");
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched3OnCombiner);
@@ -309,11 +308,11 @@ static void BM_ClosureSched2OnTwoCombiners(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
GRPC_COMBINER_UNREF(combiner1, "finished");
GRPC_COMBINER_UNREF(combiner2, "finished");
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnTwoCombiners);
@@ -336,11 +335,11 @@ static void BM_ClosureSched4OnTwoCombiners(benchmark::State& state) {
GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(&c4, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
GRPC_COMBINER_UNREF(combiner1, "finished");
GRPC_COMBINER_UNREF(combiner2, "finished");
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched4OnTwoCombiners);
@@ -379,7 +378,7 @@ static void BM_ClosureReschedOnExecCtx(benchmark::State& state) {
ExecCtx _local_exec_ctx;
Rescheduler r(state, grpc_schedule_on_exec_ctx);
r.ScheduleFirst();
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnExecCtx);
@@ -390,9 +389,9 @@ static void BM_ClosureReschedOnCombiner(benchmark::State& state) {
grpc_combiner* combiner = grpc_combiner_create();
Rescheduler r(state, grpc_combiner_scheduler(combiner));
r.ScheduleFirst();
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GRPC_COMBINER_UNREF(combiner, "finished");
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnCombiner);
@@ -403,9 +402,9 @@ static void BM_ClosureReschedOnCombinerFinally(benchmark::State& state) {
grpc_combiner* combiner = grpc_combiner_create();
Rescheduler r(state, grpc_combiner_finally_scheduler(combiner));
r.ScheduleFirstAgainstDifferentScheduler(grpc_combiner_scheduler(combiner));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
GRPC_COMBINER_UNREF(combiner, "finished");
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnCombinerFinally);
diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc
index 6d36e61cff..9fb603213a 100644
--- a/test/cpp/microbenchmarks/bm_cq.cc
+++ b/test/cpp/microbenchmarks/bm_cq.cc
@@ -84,7 +84,7 @@ static void BM_Pass1Cpp(benchmark::State& state) {
GPR_ASSERT(grpc_cq_begin_op(c_cq, &dummy_tag));
grpc_cq_end_op(c_cq, &dummy_tag, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
NULL, &completion);
- grpc_exec_ctx_finish();
+
void* tag;
bool ok;
cq.Next(&tag, &ok);
@@ -104,7 +104,7 @@ static void BM_Pass1Core(benchmark::State& state) {
GPR_ASSERT(grpc_cq_begin_op(cq, NULL));
grpc_cq_end_op(cq, NULL, GRPC_ERROR_NONE, DoneWithCompletionOnStack, NULL,
&completion);
- grpc_exec_ctx_finish();
+
grpc_completion_queue_next(cq, deadline, NULL);
}
grpc_completion_queue_destroy(cq);
@@ -123,7 +123,7 @@ static void BM_Pluck1Core(benchmark::State& state) {
GPR_ASSERT(grpc_cq_begin_op(cq, NULL));
grpc_cq_end_op(cq, NULL, GRPC_ERROR_NONE, DoneWithCompletionOnStack, NULL,
&completion);
- grpc_exec_ctx_finish();
+
grpc_completion_queue_pluck(cq, NULL, deadline, NULL);
}
grpc_completion_queue_destroy(cq);
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 41e616a6ef..0cd9a2c361 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -76,7 +76,7 @@ static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker,
GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag));
grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, NULL,
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
gpr_mu_lock(&ps->mu);
return GRPC_ERROR_NONE;
}
diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc
index 3f85e351f5..8dc98ab923 100644
--- a/test/cpp/microbenchmarks/bm_error.cc
+++ b/test/cpp/microbenchmarks/bm_error.cc
@@ -253,7 +253,7 @@ static void BM_ErrorGetStatus(benchmark::State& state) {
grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice,
NULL);
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
@@ -267,7 +267,7 @@ static void BM_ErrorGetStatusCode(benchmark::State& state) {
grpc_error_get_status(fixture.error(), fixture.deadline(), &status, NULL,
NULL);
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
@@ -281,7 +281,7 @@ static void BM_ErrorHttpError(benchmark::State& state) {
grpc_error_get_status(fixture.error(), fixture.deadline(), NULL, NULL,
&error);
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
index 74e99982ce..191c93c58d 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
@@ -183,7 +183,7 @@ class TrickledCHTTP2 : public EndpointPairFixture {
grpc_trickle_endpoint_trickle(endpoint_pair_.client);
size_t server_backlog =
grpc_trickle_endpoint_trickle(endpoint_pair_.server);
- grpc_exec_ctx_finish();
+
if (update_stats) {
UpdateStats((grpc_chttp2_transport*)client_transport_, &client_stats_,
client_backlog);
diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc
index 5d89e0d3c6..07fcf6af99 100644
--- a/test/cpp/microbenchmarks/bm_metadata.cc
+++ b/test/cpp/microbenchmarks/bm_metadata.cc
@@ -94,7 +94,7 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL));
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataFromNonInternedSlices);
@@ -107,7 +107,7 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL));
}
- grpc_exec_ctx_finish();
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -125,7 +125,7 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex(
GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL));
}
GRPC_MDELEM_UNREF(seed);
- grpc_exec_ctx_finish();
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -140,7 +140,7 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL));
}
- grpc_exec_ctx_finish();
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -157,7 +157,7 @@ static void BM_MetadataFromNonInternedSlicesWithBackingStore(
GRPC_MDELEM_UNREF(grpc_mdelem_create(
k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataFromNonInternedSlicesWithBackingStore);
@@ -173,7 +173,7 @@ static void BM_MetadataFromInternedSlicesWithBackingStore(
GRPC_MDELEM_UNREF(grpc_mdelem_create(
k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish();
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -191,7 +191,7 @@ static void BM_MetadataFromInternedKeyWithBackingStore(
GRPC_MDELEM_UNREF(grpc_mdelem_create(
k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish();
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -205,7 +205,7 @@ static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL));
}
- grpc_exec_ctx_finish();
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -220,7 +220,7 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed(
while (state.KeepRunning()) {
GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL));
}
- grpc_exec_ctx_finish();
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -237,7 +237,7 @@ static void BM_MetadataRefUnrefExternal(benchmark::State& state) {
GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
GRPC_MDELEM_UNREF(el);
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefExternal);
@@ -256,7 +256,7 @@ static void BM_MetadataRefUnrefInterned(benchmark::State& state) {
GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
GRPC_MDELEM_UNREF(el);
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefInterned);
@@ -270,7 +270,7 @@ static void BM_MetadataRefUnrefAllocated(benchmark::State& state) {
GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
GRPC_MDELEM_UNREF(el);
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefAllocated);
@@ -283,7 +283,7 @@ static void BM_MetadataRefUnrefStatic(benchmark::State& state) {
GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
GRPC_MDELEM_UNREF(el);
- grpc_exec_ctx_finish();
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefStatic);
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc
index 3da8e16788..7ddca45eca 100644
--- a/test/cpp/microbenchmarks/bm_pollset.cc
+++ b/test/cpp/microbenchmarks/bm_pollset.cc
@@ -60,9 +60,9 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
gpr_mu_lock(mu);
grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish();
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -124,7 +124,7 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish();
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -143,7 +143,7 @@ static void BM_PollAddFd(benchmark::State& state) {
grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx");
while (state.KeepRunning()) {
grpc_pollset_add_fd(ps, fd);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
}
grpc_fd_orphan(fd, NULL, NULL, false /* already_closed */, "xxx");
grpc_closure shutdown_ps_closure;
@@ -152,7 +152,7 @@ static void BM_PollAddFd(benchmark::State& state) {
gpr_mu_lock(mu);
grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish();
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -248,7 +248,7 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish();
+
grpc_wakeup_fd_destroy(&wakeup_fd);
gpr_free(ps);
track_counters.Finish(state);
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index 24b74b9d37..075064eca7 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -205,8 +205,6 @@ class EndpointPairFixture : public BaseFixture {
channel_ = CreateChannelInternal("", channel);
}
-
- grpc_exec_ctx_finish();
}
virtual ~EndpointPairFixture() {
diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc
index 836cc676c2..8ba8be0ea4 100644
--- a/test/cpp/naming/resolver_component_test.cc
+++ b/test/cpp/naming/resolver_component_test.cc
@@ -171,7 +171,7 @@ void ArgsFinish(ArgsStruct* args) {
grpc_pollset_shutdown(args->pollset, &DoNothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
grpc_channel_args_destroy(args->channel_args);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
GRPC_COMBINER_UNREF(args->lock, NULL);
@@ -202,7 +202,6 @@ void PollPollsetUntilRequestDone(ArgsStruct* args) {
grpc_timespec_to_millis_round_up(
NSecondDeadline(1))));
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish();
}
gpr_event_set(&args->ev, (void*)1);
}
@@ -295,11 +294,10 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
(void*)&args, grpc_combiner_scheduler(args.lock));
grpc_resolver_next_locked(resolver, &args.channel_args,
&on_resolver_result_changed);
- grpc_exec_ctx_flush();
+ ExecCtx::Get()->Flush();
PollPollsetUntilRequestDone(&args);
GRPC_RESOLVER_UNREF(resolver, NULL);
ArgsFinish(&args);
- grpc_exec_ctx_finish();
}
} // namespace
diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc
index b05da25e1d..b9514e6306 100644
--- a/test/cpp/performance/writes_per_rpc_test.cc
+++ b/test/cpp/performance/writes_per_rpc_test.cc
@@ -120,8 +120,6 @@ class EndpointPairFixture {
channel_ = CreateChannelInternal("", channel);
}
-
- grpc_exec_ctx_finish();
}
virtual ~EndpointPairFixture() {