aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/backoff/backoff_test.cc96
-rw-r--r--test/core/bad_client/bad_client.cc46
-rw-r--r--test/core/channel/channel_args_test.cc26
-rw-r--r--test/core/channel/channel_stack_builder_test.cc24
-rw-r--r--test/core/channel/channel_stack_test.cc45
-rw-r--r--test/core/channel/minimal_stack_is_minimal_test.cc15
-rw-r--r--test/core/client_channel/lb_policies_test.cc14
-rw-r--r--test/core/client_channel/parse_address_test.cc15
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc55
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_test.cc21
-rw-r--r--test/core/client_channel/resolvers/fake_resolver_test.cc54
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.cc28
-rw-r--r--test/core/client_channel/uri_fuzzer_test.cc6
-rw-r--r--test/core/client_channel/uri_parser_test.cc28
-rw-r--r--test/core/compression/algorithm_test.cc12
-rw-r--r--test/core/compression/message_compress_test.cc62
-rw-r--r--test/core/debug/stats_test.cc15
-rw-r--r--test/core/end2end/bad_server_response_test.cc35
-rw-r--r--test/core/end2end/connection_refused_test.cc5
-rw-r--r--test/core/end2end/fixtures/h2_census.cc10
-rw-r--r--test/core/end2end/fixtures/h2_compress.cc17
-rw-r--r--test/core/end2end/fixtures/h2_fd.cc8
-rw-r--r--test/core/end2end/fixtures/h2_full+workarounds.cc5
-rw-r--r--test/core/end2end/fixtures/h2_load_reporting.cc5
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.cc7
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.cc36
-rw-r--r--test/core/end2end/fixtures/h2_sockpair.cc33
-rw-r--r--test/core/end2end/fixtures/h2_sockpair_1byte.cc33
-rw-r--r--test/core/end2end/fixtures/h2_ssl.cc5
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.cc10
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc177
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc83
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.cc17
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.cc17
-rw-r--r--test/core/end2end/goaway_server_test.cc28
-rw-r--r--test/core/end2end/h2_ssl_cert_test.cc5
-rw-r--r--test/core/end2end/tests/cancel_after_accept.cc5
-rw-r--r--test/core/end2end/tests/cancel_after_round_trip.cc5
-rw-r--r--test/core/end2end/tests/compressed_payload.cc19
-rw-r--r--test/core/end2end/tests/filter_call_init_fails.cc19
-rw-r--r--test/core/end2end/tests/filter_causes_close.cc24
-rw-r--r--test/core/end2end/tests/filter_latency.cc18
-rw-r--r--test/core/end2end/tests/load_reporting_hook.cc5
-rw-r--r--test/core/end2end/tests/max_message_length.cc18
-rw-r--r--test/core/end2end/tests/stream_compression_compressed_payload.cc19
-rw-r--r--test/core/end2end/tests/stream_compression_payload.cc7
-rw-r--r--test/core/end2end/tests/stream_compression_ping_pong_streaming.cc7
-rw-r--r--test/core/end2end/tests/workaround_cronet_compression.cc12
-rw-r--r--test/core/handshake/readahead_handshaker_server_ssl.cc16
-rw-r--r--test/core/http/httpcli_test.cc47
-rw-r--r--test/core/http/httpscli_test.cc47
-rw-r--r--test/core/iomgr/combiner_test.cc51
-rw-r--r--test/core/iomgr/endpoint_pair_test.cc18
-rw-r--r--test/core/iomgr/endpoint_tests.cc99
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc87
-rw-r--r--test/core/iomgr/fd_conservation_posix_test.cc11
-rw-r--r--test/core/iomgr/fd_posix_test.cc141
-rw-r--r--test/core/iomgr/pollset_set_test.cc216
-rw-r--r--test/core/iomgr/resolve_address_posix_test.cc59
-rw-r--r--test/core/iomgr/resolve_address_test.cc135
-rw-r--r--test/core/iomgr/resource_quota_test.cc354
-rw-r--r--test/core/iomgr/tcp_client_posix_test.cc64
-rw-r--r--test/core/iomgr/tcp_client_uv_test.cc62
-rw-r--r--test/core/iomgr/tcp_posix_test.cc138
-rw-r--r--test/core/iomgr/tcp_server_posix_test.cc86
-rw-r--r--test/core/iomgr/tcp_server_uv_test.cc90
-rw-r--r--test/core/iomgr/timer_list_test.cc72
-rw-r--r--test/core/iomgr/udp_server_test.cc73
-rw-r--r--test/core/security/credentials_test.cc303
-rw-r--r--test/core/security/json_token_test.cc14
-rw-r--r--test/core/security/jwt_verifier_test.cc146
-rw-r--r--test/core/security/oauth2_utils.cc30
-rw-r--r--test/core/security/print_google_default_creds_token.cc22
-rw-r--r--test/core/security/secure_endpoint_test.cc46
-rw-r--r--test/core/security/ssl_server_fuzzer.cc33
-rw-r--r--test/core/security/verify_jwt.cc23
-rw-r--r--test/core/slice/b64_test.cc43
-rw-r--r--test/core/slice/slice_hash_table_test.cc37
-rw-r--r--test/core/surface/byte_buffer_reader_test.cc6
-rw-r--r--test/core/surface/channel_create_test.cc3
-rw-r--r--test/core/surface/completion_queue_test.cc39
-rw-r--r--test/core/surface/completion_queue_threading_test.cc19
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc35
-rw-r--r--test/core/surface/lame_client_test.cc13
-rw-r--r--test/core/surface/num_external_connectivity_watchers_test.cc5
-rw-r--r--test/core/surface/secure_channel_create_test.cc17
-rw-r--r--test/core/surface/sequential_connectivity_test.cc5
-rw-r--r--test/core/transport/bdp_estimator_test.cc7
-rw-r--r--test/core/transport/byte_stream_test.cc110
-rw-r--r--test/core/transport/chttp2/bin_decoder_test.cc102
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.cc91
-rw-r--r--test/core/transport/chttp2/hpack_parser_fuzzer_test.cc14
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.cc41
-rw-r--r--test/core/transport/chttp2/hpack_table_test.cc72
-rw-r--r--test/core/transport/connectivity_state_test.cc48
-rw-r--r--test/core/transport/metadata_test.cc135
-rw-r--r--test/core/transport/status_conversion_test.cc11
-rw-r--r--test/core/transport/stream_owned_slice_test.cc2
-rw-r--r--test/core/util/mock_endpoint.cc36
-rw-r--r--test/core/util/mock_endpoint.h3
-rw-r--r--test/core/util/passthru_endpoint.cc45
-rw-r--r--test/core/util/port_server_client.cc70
-rw-r--r--test/core/util/reconnect_server.cc6
-rw-r--r--test/core/util/test_tcp_server.cc36
-rw-r--r--test/core/util/trickle_endpoint.cc56
-rw-r--r--test/core/util/trickle_endpoint.h3
-rw-r--r--test/cpp/common/channel_filter_test.cc4
-rw-r--r--test/cpp/end2end/client_lb_end2end_test.cc13
-rw-r--r--test/cpp/end2end/filter_end2end_test.cc7
-rw-r--r--test/cpp/end2end/grpclb_end2end_test.cc11
-rw-r--r--test/cpp/grpclb/grpclb_test.cc17
-rw-r--r--test/cpp/microbenchmarks/bm_call_create.cc139
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc136
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_transport.cc270
-rw-r--r--test/cpp/microbenchmarks/bm_closure.cc196
-rw-r--r--test/cpp/microbenchmarks/bm_cq.cc26
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc22
-rw-r--r--test/cpp/microbenchmarks/bm_error.cc24
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_trickle.cc8
-rw-r--r--test/cpp/microbenchmarks/bm_metadata.cc115
-rw-r--r--test/cpp/microbenchmarks/bm_pollset.cc53
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h25
-rw-r--r--test/cpp/naming/resolver_component_test.cc50
-rw-r--r--test/cpp/performance/writes_per_rpc_test.cc20
124 files changed, 2654 insertions, 3331 deletions
diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc
index ef2de8d638..76a9f39c35 100644
--- a/test/core/backoff/backoff_test.cc
+++ b/test/core/backoff/backoff_test.cc
@@ -32,23 +32,24 @@ static void test_constant_backoff(void) {
const grpc_millis max_backoff = 1000;
grpc_backoff_init(&backoff, initial_backoff, multiplier, jitter,
min_connect_timeout, max_backoff);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_backoff_result next_deadlines = grpc_backoff_begin(&backoff);
+ GPR_ASSERT(next_deadlines.current_deadline -
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
GPR_ASSERT(next_deadlines.next_attempt_start_time -
- grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
for (int i = 0; i < 10000; i++) {
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) ==
+ next_deadlines = grpc_backoff_step(&backoff);
+ GPR_ASSERT(next_deadlines.current_deadline -
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
GPR_ASSERT(next_deadlines.next_attempt_start_time -
- grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
- exec_ctx.now = next_deadlines.current_deadline;
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_min_connect(void) {
@@ -60,17 +61,16 @@ static void test_min_connect(void) {
const grpc_millis max_backoff = 1000;
grpc_backoff_init(&backoff, initial_backoff, multiplier, jitter,
min_connect_timeout, max_backoff);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_backoff_result next = grpc_backoff_begin(&exec_ctx, &backoff);
+ grpc_core::ExecCtx _local_exec_ctx;
+ 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(&exec_ctx) ==
+ GPR_ASSERT(next.current_deadline - grpc_core::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(&exec_ctx) ==
+ GPR_ASSERT(next.next_attempt_start_time - grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_no_jitter_backoff(void) {
@@ -84,49 +84,47 @@ static void test_no_jitter_backoff(void) {
min_connect_timeout, max_backoff);
// x_1 = 2
// x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- exec_ctx.now = 0;
- exec_ctx.now_is_valid = true;
- grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(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;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 6);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 14);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 30);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 62);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 126);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 254);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 510);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 1022);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(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;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 2048);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 2561);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_jitter_backoff(void) {
@@ -142,12 +140,13 @@ static void test_jitter_backoff(void) {
backoff.rng_state = 0; // force consistent PRNG
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_backoff_result next_deadlines = grpc_backoff_begin(&backoff);
+ GPR_ASSERT(next_deadlines.current_deadline -
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
GPR_ASSERT(next_deadlines.next_attempt_start_time -
- grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
grpc_millis expected_next_lower_bound =
@@ -156,11 +155,11 @@ static void test_jitter_backoff(void) {
(grpc_millis)((double)current_backoff * (1 + jitter));
for (int i = 0; i < 10000; i++) {
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ next_deadlines = grpc_backoff_step(&backoff);
// 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(&exec_ctx);
+ next_deadlines.current_deadline - grpc_core::ExecCtx::Get()->Now();
GPR_ASSERT(timeout_millis >= expected_next_lower_bound);
GPR_ASSERT(timeout_millis <= expected_next_upper_bound);
current_backoff = GPR_MIN(
@@ -169,9 +168,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;
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
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 c19b7bdf40..313c43f9b3 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -50,20 +50,19 @@ static void thd_func(void* arg) {
gpr_event_set(&a->done_thd, (void*)1);
}
-static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void done_write(void* arg, grpc_error* error) {
thd_args* a = (thd_args*)arg;
gpr_event_set(&a->done_write, (void*)1);
}
static void server_setup_transport(void* ts, grpc_transport* transport) {
thd_args* a = (thd_args*)ts;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_server_setup_transport(&exec_ctx, a->server, transport, nullptr,
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_server_setup_transport(a->server, transport, nullptr,
grpc_server_get_channel_args(a->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void read_done(void* arg, grpc_error* error) {
gpr_event* read_done = (gpr_event*)arg;
gpr_event_set(read_done, (void*)1);
}
@@ -81,7 +80,7 @@ void grpc_run_bad_client_test(
grpc_slice_from_copied_buffer(client_payload, client_payload_length);
grpc_slice_buffer outgoing;
grpc_closure done_write_closure;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_completion_queue* shutdown_cq;
if (client_payload_length < 4 * 1024) {
@@ -115,14 +114,13 @@ void grpc_run_bad_client_test(
GRPC_BAD_CLIENT_REGISTERED_HOST,
GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0);
grpc_server_start(a.server);
- transport = grpc_create_chttp2_transport(&exec_ctx, nullptr, sfd.server, 0);
+ transport = grpc_create_chttp2_transport(nullptr, sfd.server, 0);
server_setup_transport(&a, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
/* Bind everything into the same pollset */
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd.client, grpc_cq_pollset(a.cq));
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd.server, grpc_cq_pollset(a.cq));
+ grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(a.cq));
+ grpc_endpoint_add_to_pollset(sfd.server, grpc_cq_pollset(a.cq));
/* Check a ground truth */
GPR_ASSERT(grpc_server_has_open_connections(a.server));
@@ -136,8 +134,7 @@ void grpc_run_bad_client_test(
grpc_schedule_on_exec_ctx);
/* Write data */
- grpc_endpoint_write(&exec_ctx, sfd.client, &outgoing, &done_write_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_write(sfd.client, &outgoing, &done_write_closure);
/* Await completion, unless the request is large and write may not finish
* before the peer shuts down. */
@@ -148,10 +145,9 @@ void grpc_run_bad_client_test(
if (flags & GRPC_BAD_CLIENT_DISCONNECT) {
grpc_endpoint_shutdown(
- &exec_ctx, sfd.client,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect"));
- grpc_endpoint_destroy(&exec_ctx, sfd.client);
- grpc_exec_ctx_finish(&exec_ctx);
+ sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect"));
+ grpc_endpoint_destroy(sfd.client);
+
sfd.client = nullptr;
}
@@ -170,9 +166,8 @@ void grpc_run_bad_client_test(
grpc_closure read_done_closure;
GRPC_CLOSURE_INIT(&read_done_closure, read_done, &read_done_event,
grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, sfd.client, &incoming,
- &read_done_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_read(sfd.client, &incoming, &read_done_closure);
+
do {
GPR_ASSERT(gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0);
GPR_ASSERT(
@@ -185,14 +180,12 @@ void grpc_run_bad_client_test(
"client validator failed; trying additional read "
"in case we didn't get all the data");
}
- grpc_slice_buffer_destroy_internal(&exec_ctx, &incoming);
+ grpc_slice_buffer_destroy_internal(&incoming);
}
// Shutdown.
grpc_endpoint_shutdown(
- &exec_ctx, sfd.client,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- grpc_endpoint_destroy(&exec_ctx, sfd.client);
- grpc_exec_ctx_finish(&exec_ctx);
+ sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ grpc_endpoint_destroy(sfd.client);
}
GPR_ASSERT(
@@ -206,8 +199,7 @@ void grpc_run_bad_client_test(
grpc_completion_queue_destroy(shutdown_cq);
grpc_server_destroy(a.server);
grpc_completion_queue_destroy(a.cq);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing);
+ grpc_slice_buffer_destroy_internal(&outgoing);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc
index e8b3334185..99a6566a1c 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -26,7 +26,7 @@
#include "test/core/util/test_config.h"
static void test_create(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_arg arg_int;
grpc_arg arg_string;
@@ -55,12 +55,11 @@ static void test_create(void) {
GPR_ASSERT(strcmp(ch_args->args[1].value.string, arg_string.value.string) ==
0);
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_set_compression_algorithm(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args* ch_args;
ch_args =
@@ -70,12 +69,11 @@ static void test_set_compression_algorithm(void) {
GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0);
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_INTEGER);
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_compression_algorithm_states(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate;
unsigned states_bitset;
size_t i;
@@ -91,10 +89,10 @@ static void test_compression_algorithm_states(void) {
/* disable gzip and deflate */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args, GRPC_COMPRESS_GZIP, 0);
+ &ch_args, GRPC_COMPRESS_GZIP, 0);
GPR_ASSERT(ch_args == ch_args_wo_gzip);
ch_args_wo_gzip_deflate = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
+ &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
@@ -109,7 +107,7 @@ static void test_compression_algorithm_states(void) {
/* re-enabled gzip only */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
+ &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
@@ -122,8 +120,7 @@ static void test_compression_algorithm_states(void) {
}
}
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_set_socket_mutator(void) {
@@ -137,9 +134,8 @@ static void test_set_socket_mutator(void) {
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_POINTER);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(ch_args);
}
}
diff --git a/test/core/channel/channel_stack_builder_test.cc b/test/core/channel/channel_stack_builder_test.cc
index a67f0efafe..ef6db81b0b 100644
--- a/test/core/channel/channel_stack_builder_test.cc
+++ b/test/core/channel/channel_stack_builder_test.cc
@@ -29,34 +29,30 @@
#include "src/core/lib/surface/channel_init.h"
#include "test/core/util/test_config.h"
-static grpc_error* channel_init_func(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* channel_init_func(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static grpc_error* call_init_func(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* call_init_func(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void channel_destroy_func(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void channel_destroy_func(grpc_channel_element* elem) {}
-static void call_destroy_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void call_destroy_func(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
-static void call_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void call_func(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {}
-static void channel_func(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
- grpc_transport_op* op) {
+static void channel_func(grpc_channel_element* elem, grpc_transport_op* op) {
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
GRPC_ERROR_UNREF(op->disconnect_with_error);
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
bool g_replacement_fn_called = false;
@@ -106,8 +102,7 @@ const grpc_channel_filter original_filter = {
grpc_channel_next_get_info,
"filter_name"};
-static bool add_replacement_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool add_replacement_filter(grpc_channel_stack_builder* builder,
void* arg) {
const grpc_channel_filter* filter =
static_cast<const grpc_channel_filter*>(arg);
@@ -118,8 +113,7 @@ static bool add_replacement_filter(grpc_exec_ctx* exec_ctx,
builder, filter, set_arg_once_fn, &g_replacement_fn_called);
}
-static bool add_original_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool add_original_filter(grpc_channel_stack_builder* builder,
void* arg) {
return grpc_channel_stack_builder_prepend_filter(
builder, (const grpc_channel_filter*)arg, set_arg_once_fn,
diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc
index 988ea9bac9..93ddd0fee5 100644
--- a/test/core/channel/channel_stack_test.cc
+++ b/test/core/channel/channel_stack_test.cc
@@ -27,8 +27,7 @@
#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/test_config.h"
-static grpc_error* channel_init_func(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* channel_init_func(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(args->channel_args->num_args == 1);
GPR_ASSERT(args->channel_args->args[0].type == GRPC_ARG_INTEGER);
@@ -40,42 +39,37 @@ static grpc_error* channel_init_func(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* call_init_func(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* call_init_func(grpc_call_element* elem,
const grpc_call_element_args* args) {
++*(int*)(elem->channel_data);
*(int*)(elem->call_data) = 0;
return GRPC_ERROR_NONE;
}
-static void channel_destroy_func(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void channel_destroy_func(grpc_channel_element* elem) {}
-static void call_destroy_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void call_destroy_func(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
++*(int*)(elem->channel_data);
}
-static void call_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void call_func(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
++*(int*)(elem->call_data);
}
-static void channel_func(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
- grpc_transport_op* op) {
+static void channel_func(grpc_channel_element* elem, grpc_transport_op* op) {
++*(int*)(elem->channel_data);
}
-static void free_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- grpc_channel_stack_destroy(exec_ctx, static_cast<grpc_channel_stack*>(arg));
+static void free_channel(void* arg, grpc_error* error) {
+ grpc_channel_stack_destroy(static_cast<grpc_channel_stack*>(arg));
gpr_free(arg);
}
-static void free_call(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- grpc_call_stack_destroy(exec_ctx, static_cast<grpc_call_stack*>(arg), nullptr,
- nullptr);
+static void free_call(void* arg, grpc_error* error) {
+ grpc_call_stack_destroy(static_cast<grpc_call_stack*>(arg), nullptr, nullptr);
gpr_free(arg);
}
@@ -101,7 +95,7 @@ static void test_create_channel_stack(void) {
grpc_channel_args chan_args;
int* channel_data;
int* call_data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_slice path = grpc_slice_from_static_string("/service/method");
arg.type = GRPC_ARG_INTEGER;
@@ -113,8 +107,8 @@ static void test_create_channel_stack(void) {
channel_stack = static_cast<grpc_channel_stack*>(
gpr_malloc(grpc_channel_stack_size(&filters, 1)));
- grpc_channel_stack_init(&exec_ctx, 1, free_channel, channel_stack, &filters,
- 1, &chan_args, nullptr, "test", channel_stack);
+ grpc_channel_stack_init(1, free_channel, channel_stack, &filters, 1,
+ &chan_args, nullptr, "test", channel_stack);
GPR_ASSERT(channel_stack->count == 1);
channel_elem = grpc_channel_stack_element(channel_stack, 0);
channel_data = (int*)channel_elem->channel_data;
@@ -132,8 +126,8 @@ static void test_create_channel_stack(void) {
nullptr, /* arena */
nullptr /* call_combiner */
};
- grpc_error* error = grpc_call_stack_init(&exec_ctx, channel_stack, 1,
- free_call, call_stack, &args);
+ grpc_error* error =
+ grpc_call_stack_init(channel_stack, 1, free_call, call_stack, &args);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(call_stack->count == 1);
call_elem = grpc_call_stack_element(call_stack, 0);
@@ -143,14 +137,13 @@ static void test_create_channel_stack(void) {
GPR_ASSERT(*call_data == 0);
GPR_ASSERT(*channel_data == 1);
- GRPC_CALL_STACK_UNREF(&exec_ctx, call_stack, "done");
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CALL_STACK_UNREF(call_stack, "done");
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(*channel_data == 2);
- GRPC_CHANNEL_STACK_UNREF(&exec_ctx, channel_stack, "done");
+ GRPC_CHANNEL_STACK_UNREF(channel_stack, "done");
- grpc_slice_unref_internal(&exec_ctx, path);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(path);
}
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 e0cffa39a8..2373bc6329 100644
--- a/test/core/channel/minimal_stack_is_minimal_test.cc
+++ b/test/core/channel/minimal_stack_is_minimal_test.cc
@@ -125,12 +125,10 @@ static int check_stack(const char* file, int line, const char* transport_name,
grpc_channel_stack_builder_set_transport(builder, &fake_transport);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_stack_builder_set_channel_arguments(&exec_ctx, builder,
- channel_args);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_stack_builder_set_channel_arguments(builder, channel_args);
GPR_ASSERT(grpc_channel_init_create_stack(
- &exec_ctx, builder, (grpc_channel_stack_type)channel_stack_type));
- grpc_exec_ctx_finish(&exec_ctx);
+ builder, (grpc_channel_stack_type)channel_stack_type));
}
// build up our expectation list
@@ -212,10 +210,9 @@ static int check_stack(const char* file, int line, const char* transport_name,
gpr_free(expect);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_stack_builder_destroy(&exec_ctx, builder);
- grpc_channel_args_destroy(&exec_ctx, channel_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_stack_builder_destroy(builder);
+ grpc_channel_args_destroy(channel_args);
}
return result;
diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc
index 5f8d3b84cc..590f934657 100644
--- a/test/core/client_channel/lb_policies_test.cc
+++ b/test/core/client_channel/lb_policies_test.cc
@@ -651,9 +651,8 @@ static void test_get_channel_info() {
grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
// Ensures that resolver returns.
grpc_channel_check_connectivity_state(channel, true /* try_to_connect */);
@@ -959,7 +958,7 @@ static void verify_rebirth_round_robin(const servers_fixture* f,
}
int main(int argc, char** argv) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
test_spec* spec;
size_t i;
const size_t NUM_ITERS = 10;
@@ -969,9 +968,9 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_tracer_set_enabled("round_robin", 1);
- GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, "this-lb-policy-does-not-exist",
- nullptr) == nullptr);
- GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, nullptr, nullptr) == nullptr);
+ GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", nullptr) ==
+ nullptr);
+ GPR_ASSERT(grpc_lb_policy_create(nullptr, nullptr) == nullptr);
spec = test_spec_create(NUM_ITERS, NUM_SERVERS);
/* everything is fine, all servers stay up the whole time and life's peachy
@@ -1025,7 +1024,6 @@ int main(int argc, char** argv) {
test_ping();
test_get_channel_info();
- grpc_exec_ctx_finish(&exec_ctx);
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 94f76da920..f64b092743 100644
--- a/test/core/client_channel/parse_address_test.cc
+++ b/test/core/client_channel/parse_address_test.cc
@@ -33,8 +33,8 @@
#ifdef GRPC_HAVE_UNIX_SOCKET
static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
GPR_ASSERT(1 == grpc_parse_unix(uri, &addr));
@@ -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(&exec_ctx);
}
#else /* GRPC_HAVE_UNIX_SOCKET */
@@ -54,8 +53,8 @@ static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {}
static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
unsigned short port) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
char ntop_buf[INET_ADDRSTRLEN];
@@ -68,13 +67,12 @@ 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(&exec_ctx);
}
static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
unsigned short port, uint32_t scope_id) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
char ntop_buf[INET6_ADDRSTRLEN];
@@ -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(&exec_ctx);
}
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 dcf315eba5..08ce148efe 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -35,8 +35,7 @@ static gpr_mu g_mu;
static bool g_fail_resolution = true;
static grpc_combiner* g_combiner;
-static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+static void my_resolve_address(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {
@@ -55,13 +54,13 @@ static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
gpr_malloc(sizeof(*(*addrs)->addrs)));
(*addrs)->addrs[0].len = 123;
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
}
static grpc_ares_request* my_dns_lookup_ares(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb,
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs, bool check_grpclb,
char** service_config_json) {
gpr_mu_lock(&g_mu);
GPR_ASSERT(0 == strcmp("test", addr));
@@ -76,27 +75,26 @@ static grpc_ares_request* my_dns_lookup_ares(
grpc_lb_addresses_set_address(*lb_addrs, 0, nullptr, 0, false, nullptr,
nullptr);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
return nullptr;
}
-static grpc_resolver* create_resolver(grpc_exec_ctx* exec_ctx,
- const char* name) {
+static grpc_resolver* create_resolver(const char* name) {
grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns");
- grpc_uri* uri = grpc_uri_parse(exec_ctx, name, 0);
+ grpc_uri* uri = grpc_uri_parse(name, 0);
GPR_ASSERT(uri);
grpc_resolver_args args;
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
grpc_resolver* resolver =
- grpc_resolver_factory_create_resolver(exec_ctx, factory, &args);
+ grpc_resolver_factory_create_resolver(factory, &args);
grpc_resolver_factory_unref(factory);
grpc_uri_destroy(uri);
return resolver;
}
-static void on_done(grpc_exec_ctx* exec_ctx, void* ev, grpc_error* error) {
+static void on_done(void* ev, grpc_error* error) {
gpr_event_set((gpr_event*)ev, (void*)1);
}
@@ -107,9 +105,8 @@ static bool wait_loop(int deadline_seconds, gpr_event* ev) {
if (gpr_event_wait(ev, grpc_timeout_seconds_to_deadline(1))) return true;
deadline_seconds--;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_timer_check(&exec_ctx, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_timer_check(nullptr);
}
return false;
}
@@ -120,16 +117,14 @@ typedef struct next_args {
grpc_closure* on_complete;
} next_args;
-static void call_resolver_next_now_lock_taken(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void call_resolver_next_now_lock_taken(void* arg,
grpc_error* error_unused) {
next_args* a = static_cast<next_args*>(arg);
- grpc_resolver_next_locked(exec_ctx, a->resolver, a->result, a->on_complete);
+ grpc_resolver_next_locked(a->resolver, a->result, a->on_complete);
gpr_free(a);
}
-static void call_resolver_next_after_locking(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver,
+static void call_resolver_next_after_locking(grpc_resolver* resolver,
grpc_channel_args** result,
grpc_closure* on_complete) {
next_args* a = static_cast<next_args*>(gpr_malloc(sizeof(*a)));
@@ -137,7 +132,6 @@ static void call_resolver_next_after_locking(grpc_exec_ctx* exec_ctx,
a->result = result;
a->on_complete = on_complete;
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a,
grpc_combiner_scheduler(resolver->combiner)),
GRPC_ERROR_NONE);
@@ -153,30 +147,29 @@ int main(int argc, char** argv) {
grpc_dns_lookup_ares = my_dns_lookup_ares;
grpc_channel_args* result = (grpc_channel_args*)1;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resolver* resolver = create_resolver(&exec_ctx, "dns:test");
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resolver* resolver = create_resolver("dns:test");
gpr_event ev1;
gpr_event_init(&ev1);
call_resolver_next_after_locking(
- &exec_ctx, resolver, &result,
+ resolver, &result,
GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(wait_loop(5, &ev1));
GPR_ASSERT(result == nullptr);
gpr_event ev2;
gpr_event_init(&ev2);
call_resolver_next_after_locking(
- &exec_ctx, resolver, &result,
+ resolver, &result,
GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(wait_loop(30, &ev2));
GPR_ASSERT(result != nullptr);
- grpc_channel_args_destroy(&exec_ctx, result);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test");
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(result);
+ GRPC_RESOLVER_UNREF(resolver, "test");
+ GRPC_COMBINER_UNREF(g_combiner, "test");
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 4c040caeb9..63d1287521 100644
--- a/test/core/client_channel/resolvers/dns_resolver_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_test.cc
@@ -28,8 +28,8 @@
static grpc_combiner* g_combiner;
static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver* resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
@@ -38,16 +38,15 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver != nullptr);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
+ GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_fails(grpc_resolver_factory* factory, const char* string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver* resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
@@ -56,10 +55,9 @@ static void test_fails(grpc_resolver_factory* factory, const char* string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver == nullptr);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char** argv) {
@@ -82,9 +80,8 @@ int main(int argc, char** argv) {
grpc_resolver_factory_unref(dns);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_COMBINER_UNREF(g_combiner, "test");
}
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 d5538e9621..ecfe43f9b7 100644
--- a/test/core/client_channel/resolvers/fake_resolver_test.cc
+++ b/test/core/client_channel/resolvers/fake_resolver_test.cc
@@ -33,7 +33,7 @@
#include "test/core/util/test_config.h"
static grpc_resolver* build_fake_resolver(
- grpc_exec_ctx* exec_ctx, grpc_combiner* combiner,
+ grpc_combiner* combiner,
grpc_fake_resolver_response_generator* response_generator) {
grpc_resolver_factory* factory = grpc_resolver_factory_lookup("fake");
grpc_arg generator_arg =
@@ -44,7 +44,7 @@ static grpc_resolver* build_fake_resolver(
args.args = &channel_args;
args.combiner = combiner;
grpc_resolver* resolver =
- grpc_resolver_factory_create_resolver(exec_ctx, factory, &args);
+ grpc_resolver_factory_create_resolver(factory, &args);
grpc_resolver_factory_unref(factory);
return resolver;
}
@@ -55,7 +55,7 @@ typedef struct on_resolution_arg {
gpr_event ev;
} on_resolution_arg;
-void on_resolution_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+void on_resolution_cb(void* arg, grpc_error* error) {
on_resolution_arg* res = static_cast<on_resolution_arg*>(arg);
// We only check the addresses channel arg because that's the only one
// explicitly set by the test via
@@ -66,24 +66,23 @@ void on_resolution_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
grpc_lb_addresses_find_channel_arg(res->expected_resolver_result);
GPR_ASSERT(
grpc_lb_addresses_cmp(actual_lb_addresses, expected_lb_addresses) == 0);
- grpc_channel_args_destroy(exec_ctx, res->resolver_result);
- grpc_channel_args_destroy(exec_ctx, res->expected_resolver_result);
+ grpc_channel_args_destroy(res->resolver_result);
+ grpc_channel_args_destroy(res->expected_resolver_result);
gpr_event_set(&res->ev, (void*)1);
}
static void test_fake_resolver() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
// Create resolver.
grpc_fake_resolver_response_generator* response_generator =
grpc_fake_resolver_response_generator_create();
- grpc_resolver* resolver =
- build_fake_resolver(&exec_ctx, combiner, response_generator);
+ grpc_resolver* resolver = build_fake_resolver(combiner, response_generator);
GPR_ASSERT(resolver != nullptr);
// Setup expectations.
- grpc_uri* uris[] = {grpc_uri_parse(&exec_ctx, "ipv4:10.2.1.1:1234", true),
- grpc_uri_parse(&exec_ctx, "ipv4:127.0.0.1:4321", true)};
+ grpc_uri* uris[] = {grpc_uri_parse("ipv4:10.2.1.1:1234", true),
+ grpc_uri_parse("ipv4:127.0.0.1:4321", true)};
const char* balancer_names[] = {"name1", "name2"};
const bool is_balancer[] = {true, false};
grpc_lb_addresses* addresses = grpc_lb_addresses_create(3, nullptr);
@@ -96,7 +95,7 @@ static void test_fake_resolver() {
grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args* results =
grpc_channel_args_copy_and_add(nullptr, &addresses_arg, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
+ grpc_lb_addresses_destroy(addresses);
on_resolution_arg on_res_arg;
memset(&on_res_arg, 0, sizeof(on_res_arg));
on_res_arg.expected_resolver_result = results;
@@ -106,17 +105,16 @@ static void test_fake_resolver() {
// Set resolver results and trigger first resolution. on_resolution_cb
// performs the checks.
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, results);
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ results);
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
// Setup update.
- grpc_uri* uris_update[] = {
- grpc_uri_parse(&exec_ctx, "ipv4:192.168.1.0:31416", true)};
+ grpc_uri* uris_update[] = {grpc_uri_parse("ipv4:192.168.1.0:31416", true)};
const char* balancer_names_update[] = {"name3"};
const bool is_balancer_update[] = {false};
grpc_lb_addresses* addresses_update = grpc_lb_addresses_create(1, nullptr);
@@ -131,7 +129,7 @@ static void test_fake_resolver() {
grpc_lb_addresses_create_channel_arg(addresses_update);
grpc_channel_args* results_update =
grpc_channel_args_copy_and_add(nullptr, &addresses_update_arg, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses_update);
+ grpc_lb_addresses_destroy(addresses_update);
// Setup expectations for the update.
on_resolution_arg on_res_arg_update;
@@ -142,27 +140,27 @@ static void test_fake_resolver() {
grpc_combiner_scheduler(combiner));
// Set updated resolver results and trigger a second resolution.
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, results_update);
- grpc_resolver_next_locked(&exec_ctx, resolver,
- &on_res_arg_update.resolver_result, on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ results_update);
+ grpc_resolver_next_locked(resolver, &on_res_arg_update.resolver_result,
+ on_resolution);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg_update.ev,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
// Requesting a new resolution without re-senting the response shouldn't
// trigger the resolution callback.
memset(&on_res_arg, 0, sizeof(on_res_arg));
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "test_fake_resolver");
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_fake_resolver");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "test_fake_resolver");
+ GRPC_RESOLVER_UNREF(resolver, "test_fake_resolver");
+
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 dfa2d12b5e..f3711c151e 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
@@ -35,14 +35,14 @@ typedef struct on_resolution_arg {
grpc_channel_args* resolver_result;
} on_resolution_arg;
-void on_resolution_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+void on_resolution_cb(void* arg, grpc_error* error) {
on_resolution_arg* res = static_cast<on_resolution_arg*>(arg);
- grpc_channel_args_destroy(exec_ctx, res->resolver_result);
+ grpc_channel_args_destroy(res->resolver_result);
}
static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver* resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
@@ -51,7 +51,7 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver != nullptr);
on_resolution_arg on_res_arg;
@@ -60,16 +60,16 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
grpc_closure* on_resolution = GRPC_CLOSURE_CREATE(
on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx);
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
+
grpc_uri_destroy(uri);
}
static void test_fails(grpc_resolver_factory* factory, const char* string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver* resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
@@ -78,10 +78,9 @@ static void test_fails(grpc_resolver_factory* factory, const char* string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver == nullptr);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char** argv) {
@@ -112,9 +111,8 @@ int main(int argc, char** argv) {
grpc_resolver_factory_unref(ipv6);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_COMBINER_UNREF(g_combiner, "test");
}
grpc_shutdown();
diff --git a/test/core/client_channel/uri_fuzzer_test.cc b/test/core/client_channel/uri_fuzzer_test.cc
index ba31793ff3..484676e472 100644
--- a/test/core/client_channel/uri_fuzzer_test.cc
+++ b/test/core/client_channel/uri_fuzzer_test.cc
@@ -33,12 +33,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
memcpy(s, data, size);
s[size] = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_uri* x;
- if ((x = grpc_uri_parse(&exec_ctx, s, 1))) {
+ if ((x = grpc_uri_parse(s, 1))) {
grpc_uri_destroy(x);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
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 30183f9f57..1694f2363d 100644
--- a/test/core/client_channel/uri_parser_test.cc
+++ b/test/core/client_channel/uri_parser_test.cc
@@ -28,29 +28,28 @@
static void test_succeeds(const char* uri_text, const char* scheme,
const char* authority, const char* path,
const char* query, const char* fragment) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp(scheme, uri->scheme));
GPR_ASSERT(0 == strcmp(authority, uri->authority));
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(&exec_ctx);
+
grpc_uri_destroy(uri);
}
static void test_fails(const char* uri_text) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(nullptr == grpc_uri_parse(&exec_ctx, uri_text, 0));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(nullptr == grpc_uri_parse(uri_text, 0));
}
static void test_query_parts() {
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
const char* uri_text = "http://foo/path?a&b=B&c=&#frag";
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -77,14 +76,14 @@ static void test_query_parts() {
GPR_ASSERT(nullptr == grpc_uri_get_query_arg(uri, ""));
GPR_ASSERT(0 == strcmp("frag", uri->fragment));
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_uri_destroy(uri);
}
{
/* test the current behavior of multiple query part values */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
const char* uri_text = "http://auth/path?foo=bar=baz&foobar==";
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -96,14 +95,13 @@ 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(&exec_ctx);
grpc_uri_destroy(uri);
}
{
/* empty query */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
const char* uri_text = "http://foo/path";
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -114,7 +112,7 @@ static void test_query_parts() {
GPR_ASSERT(nullptr == uri->query_parts);
GPR_ASSERT(nullptr == uri->query_parts_values);
GPR_ASSERT(0 == strcmp("", uri->fragment));
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_uri_destroy(uri);
}
}
diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc
index 2f1d8bc8eb..b0613c4b7d 100644
--- a/test/core/compression/algorithm_test.cc
+++ b/test/core/compression/algorithm_test.cc
@@ -39,7 +39,7 @@ static void test_algorithm_mesh(void) {
grpc_compression_algorithm parsed;
grpc_slice mdstr;
grpc_mdelem mdelem;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(
grpc_compression_algorithm_name((grpc_compression_algorithm)i, &name));
GPR_ASSERT(grpc_compression_algorithm_parse(
@@ -51,9 +51,8 @@ static void test_algorithm_mesh(void) {
mdelem = grpc_compression_encoding_mdelem(parsed);
GPR_ASSERT(grpc_slice_eq(GRPC_MDVALUE(mdelem), mdstr));
GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING));
- grpc_slice_unref_internal(&exec_ctx, mdstr);
- GRPC_MDELEM_UNREF(&exec_ctx, mdelem);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(mdstr);
+ GRPC_MDELEM_UNREF(mdelem);
}
/* test failure */
@@ -62,7 +61,7 @@ static void test_algorithm_mesh(void) {
}
static void test_algorithm_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_slice mdstr;
gpr_log(GPR_DEBUG, "test_algorithm_failure");
@@ -83,8 +82,7 @@ static void test_algorithm_failure(void) {
grpc_compression_algorithm_slice(static_cast<grpc_compression_algorithm>(
static_cast<int>(GRPC_COMPRESS_ALGORITHMS_COUNT) + 1)),
grpc_empty_slice()));
- grpc_slice_unref_internal(&exec_ctx, mdstr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(mdstr);
}
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 676415ba9d..0145b4f402 100644
--- a/test/core/compression/message_compress_test.cc
+++ b/test/core/compression/message_compress_test.cc
@@ -70,10 +70,8 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slices_to_buffer(uncompressed_split_mode, &value, 1, &input);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_compressed =
- grpc_msg_compress(&exec_ctx, algorithm, &input, &compressed_raw);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ was_compressed = grpc_msg_compress(algorithm, &input, &compressed_raw);
}
GPR_ASSERT(input.count > 0);
@@ -92,11 +90,9 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slice_buffer(compressed_split_mode, &compressed_raw, &compressed);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_msg_decompress(
- &exec_ctx, was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed, &output));
}
final = grpc_slice_merge(output.slices, output.count);
@@ -156,11 +152,11 @@ static void test_tiny_data_compress(void) {
for (int i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_NONE) continue;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_compress(
- &exec_ctx, static_cast<grpc_compression_algorithm>(i),
- &input, &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(0 ==
+ grpc_msg_compress(static_cast<grpc_compression_algorithm>(i),
+ &input, &output));
+
GPR_ASSERT(1 == output.count);
}
@@ -180,9 +176,9 @@ static void test_bad_decompression_data_crc(void) {
grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(&input, create_test_value(ONE_MB_A));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* compress it */
- grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_GZIP, &input, &corrupted);
+ grpc_msg_compress(GRPC_COMPRESS_GZIP, &input, &corrupted);
/* corrupt the output by smashing the CRC */
GPR_ASSERT(corrupted.count > 1);
GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8);
@@ -190,9 +186,7 @@ static void test_bad_decompression_data_crc(void) {
memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4);
/* try (and fail) to decompress the corrupted compresed buffer */
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_GZIP, &corrupted,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_GZIP, &corrupted, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&corrupted);
@@ -211,10 +205,8 @@ static void test_bad_decompression_data_trailing_garbage(void) {
"\x78\xda\x63\x60\x60\x60\x00\x00\x00\x04\x00\x01\x99", 13));
/* try (and fail) to decompress the invalid compresed buffer */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -230,10 +222,8 @@ static void test_bad_decompression_data_stream(void) {
grpc_slice_from_copied_buffer("\x78\xda\xff\xff", 4));
/* try (and fail) to decompress the invalid compresed buffer */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -249,17 +239,15 @@ static void test_bad_compression_algorithm(void) {
grpc_slice_buffer_add(
&input, grpc_slice_from_copied_string("Never gonna give you up"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_compressed = grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT,
- &input, &output);
+ grpc_core::ExecCtx _local_exec_ctx;
+ was_compressed =
+ grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
GPR_ASSERT(0 == was_compressed);
- was_compressed = grpc_msg_compress(&exec_ctx,
- static_cast<grpc_compression_algorithm>(
+ was_compressed = grpc_msg_compress(static_cast<grpc_compression_algorithm>(
GRPC_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_compressed);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -275,18 +263,16 @@ static void test_bad_decompression_algorithm(void) {
grpc_slice_buffer_add(&input,
grpc_slice_from_copied_string(
"I'm not really compressed but it doesn't matter"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_decompressed = grpc_msg_decompress(
- &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ grpc_core::ExecCtx _local_exec_ctx;
+ was_decompressed =
+ grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
GPR_ASSERT(0 == was_decompressed);
was_decompressed =
- grpc_msg_decompress(&exec_ctx,
- static_cast<grpc_compression_algorithm>(
+ grpc_msg_decompress(static_cast<grpc_compression_algorithm>(
GRPC_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_decompressed);
- grpc_exec_ctx_finish(&exec_ctx);
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 5fae61f8f6..1623e7c8a4 100644
--- a/test/core/debug/stats_test.cc
+++ b/test/core/debug/stats_test.cc
@@ -49,9 +49,8 @@ TEST(StatsTest, IncCounters) {
for (int i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
Snapshot snapshot;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_STATS_INC_COUNTER(&exec_ctx, (grpc_stats_counters)i);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_STATS_INC_COUNTER((grpc_stats_counters)i);
EXPECT_EQ(snapshot.delta().counters[i], 1);
}
@@ -60,9 +59,8 @@ TEST(StatsTest, IncCounters) {
TEST(StatsTest, IncSpecificCounter) {
Snapshot snapshot;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_STATS_INC_SYSCALL_POLL(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_STATS_INC_SYSCALL_POLL();
EXPECT_EQ(snapshot.delta().counters[GRPC_STATS_COUNTER_SYSCALL_POLL], 1);
}
@@ -94,9 +92,8 @@ TEST_P(HistogramTest, IncHistogram) {
for (auto j : test_values) {
Snapshot snapshot;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_stats_inc_histogram[kHistogram](&exec_ctx, j);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_stats_inc_histogram[kHistogram](j);
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 b0c6ae926e..576d39b319 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -91,22 +91,22 @@ static grpc_closure on_write;
static void* tag(intptr_t t) { return (void*)t; }
-static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void done_write(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
gpr_atm_rel_store(&state.done_atm, 1);
}
-static void handle_write(grpc_exec_ctx* exec_ctx) {
+static void handle_write() {
grpc_slice slice = grpc_slice_from_copied_buffer(
state.response_payload, state.response_payload_length);
grpc_slice_buffer_reset_and_unref(&state.outgoing_buffer);
grpc_slice_buffer_add(&state.outgoing_buffer, slice);
- grpc_endpoint_write(exec_ctx, state.tcp, &state.outgoing_buffer, &on_write);
+ grpc_endpoint_write(state.tcp, &state.outgoing_buffer, &on_write);
}
-static void handle_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void handle_read(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
state.incoming_data_length += state.temp_incoming_buffer.length;
@@ -123,14 +123,13 @@ static void handle_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD);
if (state.incoming_data_length >=
SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD) {
- handle_write(exec_ctx);
+ handle_write();
} else {
- grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer,
- &on_read);
+ grpc_endpoint_read(state.tcp, &state.temp_incoming_buffer, &on_read);
}
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
+static void on_connect(void* arg, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
@@ -141,8 +140,8 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
grpc_slice_buffer_init(&state.outgoing_buffer);
state.tcp = tcp;
state.incoming_data_length = 0;
- grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset);
- grpc_endpoint_read(exec_ctx, tcp, &state.temp_incoming_buffer, &on_read);
+ grpc_endpoint_add_to_pollset(tcp, server->pollset);
+ grpc_endpoint_read(tcp, &state.temp_incoming_buffer, &on_read);
}
static gpr_timespec n_sec_deadline(int seconds) {
@@ -217,10 +216,10 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
cq_verifier_destroy(cqv);
}
-static void cleanup_rpc(grpc_exec_ctx* exec_ctx) {
+static void cleanup_rpc() {
grpc_event ev;
- grpc_slice_buffer_destroy_internal(exec_ctx, &state.temp_incoming_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &state.outgoing_buffer);
+ grpc_slice_buffer_destroy_internal(&state.temp_incoming_buffer);
+ grpc_slice_buffer_destroy_internal(&state.outgoing_buffer);
grpc_call_unref(state.call);
grpc_completion_queue_shutdown(state.cq);
do {
@@ -270,7 +269,7 @@ static void run_test(const char* response_payload,
grpc_status_code expected_status,
const char* expected_detail) {
test_tcp_server test_server;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_event ev;
grpc_init();
@@ -287,11 +286,11 @@ static void run_test(const char* response_payload,
gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));
/* clean up */
- grpc_endpoint_shutdown(&exec_ctx, state.tcp,
+ grpc_endpoint_shutdown(state.tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- grpc_endpoint_destroy(&exec_ctx, state.tcp);
- cleanup_rpc(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_destroy(state.tcp);
+ cleanup_rpc();
+
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 f3f2dda91d..9904c1384c 100644
--- a/test/core/end2end/connection_refused_test.cc
+++ b/test/core/end2end/connection_refused_test.cc
@@ -133,9 +133,8 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
grpc_metadata_array_destroy(&trailing_metadata_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (args != nullptr) grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ if (args != nullptr) grpc_channel_args_destroy(args);
}
grpc_shutdown();
diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc
index fed8ead5c8..60aafc3b94 100644
--- a/test/core/end2end/fixtures/h2_census.cc
+++ b/test/core/end2end/fixtures/h2_census.cc
@@ -75,9 +75,8 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
}
}
@@ -92,9 +91,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
f->server = grpc_server_create(server_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(server_args);
}
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
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 ea8990fd0a..040c041f38 100644
--- a/test/core/end2end/fixtures/h2_compress.cc
+++ b/test/core/end2end/fixtures/h2_compress.cc
@@ -66,9 +66,8 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f,
fullstack_compression_fixture_data* ffd =
static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
if (ffd->client_args_compression != nullptr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(ffd->client_args_compression);
}
ffd->client_args_compression = grpc_channel_args_set_compression_algorithm(
client_args, GRPC_COMPRESS_GZIP);
@@ -81,9 +80,8 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f,
fullstack_compression_fixture_data* ffd =
static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
if (ffd->server_args_compression != nullptr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(ffd->server_args_compression);
}
ffd->server_args_compression = grpc_channel_args_set_compression_algorithm(
server_args, GRPC_COMPRESS_GZIP);
@@ -97,14 +95,13 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f,
}
void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
fullstack_compression_fixture_data* ffd =
static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
- grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression);
- grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression);
+ grpc_channel_args_destroy(ffd->client_args_compression);
+ grpc_channel_args_destroy(ffd->server_args_compression);
gpr_free(ffd->localaddr);
gpr_free(ffd);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* All test configurations */
diff --git a/test/core/end2end/fixtures/h2_fd.cc b/test/core/end2end/fixtures/h2_fd.cc
index 97f4b71bf0..85f5061ee8 100644
--- a/test/core/end2end/fixtures/h2_fd.cc
+++ b/test/core/end2end/fixtures/h2_fd.cc
@@ -68,20 +68,18 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
sp_fixture_data* sfd = static_cast<sp_fixture_data*>(f->fixture_data);
GPR_ASSERT(!f->client);
f->client = grpc_insecure_channel_create_from_fd(
"fixture_client", sfd->fd_pair[0], client_args);
GPR_ASSERT(f->client);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
sp_fixture_data* sfd = static_cast<sp_fixture_data*>(f->fixture_data);
GPR_ASSERT(!f->server);
f->server = grpc_server_create(server_args, nullptr);
@@ -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, nullptr, sfd->fd_pair[1]);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
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 71a497d796..2f9a9d4c4b 100644
--- a/test/core/end2end/fixtures/h2_full+workarounds.cc
+++ b/test/core/end2end/fixtures/h2_full+workarounds.cc
@@ -72,7 +72,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
fullstack_fixture_data* ffd =
static_cast<fullstack_fixture_data*>(f->fixture_data);
grpc_arg args[GRPC_MAX_WORKAROUND_ID];
@@ -90,8 +90,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
- grpc_channel_args_destroy(&exec_ctx, server_args_new);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(server_args_new);
}
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 7486b6af78..61853740ab 100644
--- a/test/core/end2end/fixtures/h2_load_reporting.cc
+++ b/test/core/end2end/fixtures/h2_load_reporting.cc
@@ -78,9 +78,8 @@ void chttp2_init_server_load_reporting(grpc_end2end_test_fixture* f,
server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
f->server = grpc_server_create(server_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(server_args);
}
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
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 1642cb0db9..40ca2a77fb 100644
--- a/test/core/end2end/fixtures/h2_oauth2.cc
+++ b/test/core/end2end/fixtures/h2_oauth2.cc
@@ -143,11 +143,11 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_credentials* ssl_creds =
grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create(
- &exec_ctx, "authorization", oauth2_md, true /* is_async */);
+ "authorization", oauth2_md, true /* is_async */);
grpc_channel_credentials* ssl_oauth2_creds =
grpc_composite_channel_credentials_create(ssl_creds, oauth2_creds,
nullptr);
@@ -158,10 +158,9 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_channel_args* new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds);
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
+ grpc_channel_args_destroy(new_client_args);
grpc_channel_credentials_release(ssl_creds);
grpc_call_credentials_release(oauth2_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
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 fe4ab74843..b8b18e2a95 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.cc
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc
@@ -50,12 +50,11 @@
static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq));
- grpc_server_setup_transport(&exec_ctx, f->server, transport, nullptr,
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
@@ -63,13 +62,11 @@ typedef struct {
grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts,
- grpc_transport* transport) {
+static void client_setup_transport(void* ts, grpc_transport* transport) {
sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
@@ -90,34 +87,30 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, 1);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
GPR_ASSERT(!f->server);
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
@@ -133,7 +126,7 @@ static grpc_end2end_test_config configs[] = {
int main(int argc, char** argv) {
size_t i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* force tracing on, with a value to force many
code paths in trace.c to be taken */
@@ -147,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(&exec_ctx);
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 59a3a6db31..304d0dd1fa 100644
--- a/test/core/end2end/fixtures/h2_sockpair.cc
+++ b/test/core/end2end/fixtures/h2_sockpair.cc
@@ -44,12 +44,11 @@
static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq));
- grpc_server_setup_transport(&exec_ctx, f->server, transport, nullptr,
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
@@ -57,13 +56,11 @@ typedef struct {
grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts,
- grpc_transport* transport) {
+static void client_setup_transport(void* ts, grpc_transport* transport) {
sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
@@ -84,34 +81,30 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, 1);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
GPR_ASSERT(!f->server);
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
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 d935efbbac..0b5ae3abe4 100644
--- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc
+++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
@@ -44,12 +44,11 @@
static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq));
- grpc_server_setup_transport(&exec_ctx, f->server, transport, nullptr,
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
@@ -57,13 +56,11 @@ typedef struct {
grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts,
- grpc_transport* transport) {
+static void client_setup_transport(void* ts, grpc_transport* transport) {
sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
@@ -95,34 +92,30 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, 1);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
GPR_ASSERT(!f->server);
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
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 3d7e2e327e..4d6fed14e0 100644
--- a/test/core/end2end/fixtures/h2_ssl.cc
+++ b/test/core/end2end/fixtures/h2_ssl.cc
@@ -110,9 +110,8 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
}
diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc
index f8d5a699e4..aee1388a56 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.cc
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc
@@ -66,9 +66,8 @@ static grpc_channel* create_proxy_client(const char* target,
grpc_secure_channel_create(ssl_creds, target, new_client_args, nullptr);
grpc_channel_credentials_release(ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
return channel;
}
@@ -148,9 +147,8 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
}
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index 0bdd15c57d..5ac783611d 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -102,24 +102,21 @@ static void proxy_connection_ref(proxy_connection* conn, const char* reason) {
}
// Helper function to destroy the proxy connection.
-static void proxy_connection_unref(grpc_exec_ctx* exec_ctx,
- proxy_connection* conn, const char* reason) {
+static void proxy_connection_unref(proxy_connection* conn, const char* reason) {
if (gpr_unref(&conn->refcount)) {
gpr_log(GPR_DEBUG, "endpoints: %p %p", conn->client_endpoint,
conn->server_endpoint);
- grpc_endpoint_destroy(exec_ctx, conn->client_endpoint);
+ grpc_endpoint_destroy(conn->client_endpoint);
if (conn->server_endpoint != nullptr) {
- grpc_endpoint_destroy(exec_ctx, conn->server_endpoint);
+ grpc_endpoint_destroy(conn->server_endpoint);
}
- grpc_pollset_set_destroy(exec_ctx, conn->pollset_set);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->client_read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &conn->client_deferred_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->client_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->server_read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &conn->server_deferred_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->server_write_buffer);
+ grpc_pollset_set_destroy(conn->pollset_set);
+ grpc_slice_buffer_destroy_internal(&conn->client_read_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->client_deferred_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->client_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_read_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_deferred_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_write_buffer);
grpc_http_parser_destroy(&conn->http_parser);
grpc_http_request_destroy(&conn->http_request);
gpr_unref(&conn->proxy->users);
@@ -129,27 +126,23 @@ static void proxy_connection_unref(grpc_exec_ctx* exec_ctx,
// Helper function to shut down the proxy connection.
// Does NOT take ownership of a reference to error.
-static void proxy_connection_failed(grpc_exec_ctx* exec_ctx,
- proxy_connection* conn, bool is_client,
+static void proxy_connection_failed(proxy_connection* conn, bool is_client,
const char* prefix, grpc_error* error) {
const char* msg = grpc_error_string(error);
gpr_log(GPR_INFO, "%s: %s", prefix, msg);
- grpc_endpoint_shutdown(exec_ctx, conn->client_endpoint,
- GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(conn->client_endpoint, GRPC_ERROR_REF(error));
if (conn->server_endpoint != nullptr) {
- grpc_endpoint_shutdown(exec_ctx, conn->server_endpoint,
- GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(conn->server_endpoint, GRPC_ERROR_REF(error));
}
- proxy_connection_unref(exec_ctx, conn, "conn_failed");
+ proxy_connection_unref(conn, "conn_failed");
}
// Callback for writing proxy data to the client.
-static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_client_write_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy client write", error);
return;
}
@@ -160,21 +153,19 @@ static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
if (conn->client_deferred_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->client_deferred_write_buffer,
&conn->client_write_buffer);
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_client_write_done);
} else {
// No more writes. Unref the connection.
- proxy_connection_unref(exec_ctx, conn, "write_done");
+ proxy_connection_unref(conn, "write_done");
}
}
// Callback for writing proxy data to the backend server.
-static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_write_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, false /* is_client */,
+ proxy_connection_failed(conn, false /* is_client */,
"HTTP proxy server write", error);
return;
}
@@ -185,22 +176,20 @@ static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg,
if (conn->server_deferred_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->server_deferred_write_buffer,
&conn->server_write_buffer);
- grpc_endpoint_write(exec_ctx, conn->server_endpoint,
- &conn->server_write_buffer,
+ grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
&conn->on_server_write_done);
} else {
// No more writes. Unref the connection.
- proxy_connection_unref(exec_ctx, conn, "server_write");
+ proxy_connection_unref(conn, "server_write");
}
}
// Callback for reading data from the client, which will be proxied to
// the backend server.
-static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_client_read_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy client read", error);
return;
}
@@ -217,22 +206,20 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_move_into(&conn->client_read_buffer,
&conn->server_write_buffer);
proxy_connection_ref(conn, "client_read");
- grpc_endpoint_write(exec_ctx, conn->server_endpoint,
- &conn->server_write_buffer,
+ grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
&conn->on_server_write_done);
}
// Read more data.
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_client_read_done);
}
// Callback for reading data from the backend server, which will be
// proxied to the client.
-static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_read_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, false /* is_client */,
+ proxy_connection_failed(conn, false /* is_client */,
"HTTP proxy server read", error);
return;
}
@@ -249,21 +236,19 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_move_into(&conn->server_read_buffer,
&conn->client_write_buffer);
proxy_connection_ref(conn, "server_read");
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_client_write_done);
}
// Read more data.
- grpc_endpoint_read(exec_ctx, conn->server_endpoint, &conn->server_read_buffer,
+ grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
&conn->on_server_read_done);
}
// Callback to write the HTTP response for the CONNECT request.
-static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_write_response_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy write response", error);
return;
}
@@ -274,17 +259,16 @@ static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg,
// for the other one.
proxy_connection_ref(conn, "client_read");
proxy_connection_ref(conn, "server_read");
- proxy_connection_unref(exec_ctx, conn, "write_response");
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ proxy_connection_unref(conn, "write_response");
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_client_read_done);
- grpc_endpoint_read(exec_ctx, conn->server_endpoint, &conn->server_read_buffer,
+ grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
&conn->on_server_read_done);
}
// Callback to connect to the backend server specified by the HTTP
// CONNECT request.
-static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_connect_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
// TODO(roth): Technically, in this case, we should handle the error
@@ -292,7 +276,7 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
// connection failed. However, for the purposes of this test code,
// it's fine to pretend this is a client-side error, which will
// cause the client connection to be dropped.
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy server connect", error);
return;
}
@@ -302,8 +286,7 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice slice =
grpc_slice_from_copied_string("HTTP/1.0 200 connected\r\n\r\n");
grpc_slice_buffer_add(&conn->client_write_buffer, slice);
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_write_response_done);
}
@@ -312,8 +295,7 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
* Basic <base64_encoded_expected_cred>
* Returns true if it matches, false otherwise
*/
-static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
- char* proxy_auth_header_val,
+static bool proxy_auth_header_matches(char* proxy_auth_header_val,
char* expected_cred) {
GPR_ASSERT(proxy_auth_header_val != nullptr);
GPR_ASSERT(expected_cred != nullptr);
@@ -321,11 +303,10 @@ static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
return false;
}
proxy_auth_header_val += 6;
- grpc_slice decoded_slice =
- grpc_base64_decode(exec_ctx, proxy_auth_header_val, 0);
+ grpc_slice decoded_slice = grpc_base64_decode(proxy_auth_header_val, 0);
const bool header_matches =
grpc_slice_str_cmp(decoded_slice, expected_cred) == 0;
- grpc_slice_unref_internal(exec_ctx, decoded_slice);
+ grpc_slice_unref_internal(decoded_slice);
return header_matches;
}
@@ -335,13 +316,12 @@ static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
// the client indicating that the request failed. However, for the purposes
// of this test code, it's fine to pretend this is a client-side error,
// which will cause the client connection to be dropped.
-static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_read_request_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn,
grpc_error_string(error));
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy read request", error);
return;
}
@@ -351,7 +331,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
error = grpc_http_parser_parse(
&conn->http_parser, conn->client_read_buffer.slices[i], nullptr);
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy request parse", error);
GRPC_ERROR_UNREF(error);
return;
@@ -361,8 +341,8 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_reset_and_unref(&conn->client_read_buffer);
// If we're not done reading the request, read more data.
if (conn->http_parser.state != GRPC_HTTP_BODY) {
- grpc_endpoint_read(exec_ctx, conn->client_endpoint,
- &conn->client_read_buffer, &conn->on_read_request_done);
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
+ &conn->on_read_request_done);
return;
}
// Make sure we got a CONNECT request.
@@ -372,7 +352,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
conn->http_request.method);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy read request", error);
GRPC_ERROR_UNREF(error);
return;
@@ -385,15 +365,14 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
for (size_t i = 0; i < conn->http_request.hdr_count; i++) {
if (strcmp(conn->http_request.hdrs[i].key, "Proxy-Authorization") == 0) {
client_authenticated = proxy_auth_header_matches(
- exec_ctx, conn->http_request.hdrs[i].value,
- proxy_auth_arg->value.string);
+ conn->http_request.hdrs[i].value, proxy_auth_arg->value.string);
break;
}
}
if (!client_authenticated) {
const char* msg = "HTTP Connect could not verify authentication";
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(msg);
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy read request", error);
GRPC_ERROR_UNREF(error);
return;
@@ -404,8 +383,8 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
error = grpc_blocking_resolve_address(conn->http_request.path, "80",
&resolved_addresses);
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy DNS lookup", error);
+ proxy_connection_failed(conn, true /* is_client */, "HTTP proxy DNS lookup",
+ error);
GRPC_ERROR_UNREF(error);
return;
}
@@ -413,15 +392,15 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
// Connect to requested address.
// The connection callback inherits our reference to conn.
const grpc_millis deadline =
- grpc_exec_ctx_now(exec_ctx) + 10 * GPR_MS_PER_SEC;
- grpc_tcp_client_connect(exec_ctx, &conn->on_server_connect_done,
- &conn->server_endpoint, conn->pollset_set, nullptr,
+ grpc_core::ExecCtx::Get()->Now() + 10 * GPR_MS_PER_SEC;
+ grpc_tcp_client_connect(&conn->on_server_connect_done, &conn->server_endpoint,
+ conn->pollset_set, nullptr,
&resolved_addresses->addrs[0], deadline);
grpc_resolved_addresses_destroy(resolved_addresses);
}
-static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_endpoint* endpoint, grpc_pollset* accepting_pollset,
+static void on_accept(void* arg, grpc_endpoint* endpoint,
+ grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
@@ -432,8 +411,8 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
conn->proxy = proxy;
gpr_ref_init(&conn->refcount, 1);
conn->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, conn->pollset_set, proxy->pollset);
- grpc_endpoint_add_to_pollset_set(exec_ctx, endpoint, conn->pollset_set);
+ grpc_pollset_set_add_pollset(conn->pollset_set, proxy->pollset);
+ grpc_endpoint_add_to_pollset_set(endpoint, conn->pollset_set);
GRPC_CLOSURE_INIT(&conn->on_read_request_done, on_read_request_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_server_connect_done, on_server_connect_done, conn,
@@ -456,7 +435,7 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_init(&conn->server_write_buffer);
grpc_http_parser_init(&conn->http_parser, GRPC_HTTP_REQUEST,
&conn->http_request);
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_read_request_done);
}
@@ -466,24 +445,23 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
static void thread_main(void* arg) {
grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
do {
gpr_ref(&proxy->users);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(proxy->mu);
GRPC_LOG_IF_ERROR(
"grpc_pollset_work",
- grpc_pollset_work(&exec_ctx, proxy->pollset, &worker,
- grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC));
+ grpc_pollset_work(proxy->pollset, &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC));
gpr_mu_unlock(proxy->mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
} while (!gpr_unref(&proxy->users));
- grpc_exec_ctx_finish(&exec_ctx);
}
grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
grpc_channel_args* args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_end2end_http_proxy* proxy =
(grpc_end2end_http_proxy*)gpr_malloc(sizeof(*proxy));
memset(proxy, 0, sizeof(*proxy));
@@ -495,8 +473,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name);
// Create TCP server.
proxy->channel_args = grpc_channel_args_copy(args);
- grpc_error* error = grpc_tcp_server_create(
- &exec_ctx, nullptr, proxy->channel_args, &proxy->server);
+ grpc_error* error =
+ grpc_tcp_server_create(nullptr, proxy->channel_args, &proxy->server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
// Bind to port.
grpc_resolved_address resolved_addr;
@@ -511,9 +489,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
// Start server.
proxy->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(proxy->pollset, &proxy->mu);
- grpc_tcp_server_start(&exec_ctx, proxy->server, &proxy->pollset, 1, on_accept,
- proxy);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(proxy->server, &proxy->pollset, 1, on_accept, proxy);
+
// Start proxy thread.
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
@@ -521,27 +498,25 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
return proxy;
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void destroy_pollset(void* arg, grpc_error* error) {
grpc_pollset* pollset = (grpc_pollset*)arg;
- grpc_pollset_destroy(exec_ctx, pollset);
+ grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) {
gpr_unref(&proxy->users); // Signal proxy thread to shutdown.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_thd_join(proxy->thd);
- grpc_tcp_server_shutdown_listeners(&exec_ctx, proxy->server);
- grpc_tcp_server_unref(&exec_ctx, proxy->server);
+ grpc_tcp_server_shutdown_listeners(proxy->server);
+ grpc_tcp_server_unref(proxy->server);
gpr_free(proxy->proxy_name);
- grpc_channel_args_destroy(&exec_ctx, proxy->channel_args);
- grpc_pollset_shutdown(&exec_ctx, proxy->pollset,
+ grpc_channel_args_destroy(proxy->channel_args);
+ grpc_pollset_shutdown(proxy->pollset,
GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset,
grpc_schedule_on_exec_ctx));
- GRPC_COMBINER_UNREF(&exec_ctx, proxy->combiner, "test");
+ GRPC_COMBINER_UNREF(proxy->combiner, "test");
gpr_free(proxy);
- grpc_exec_ctx_finish(&exec_ctx);
}
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 b8ec12586e..ce916bd341 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -376,8 +376,7 @@ typedef struct addr_req {
grpc_lb_addresses** lb_addrs;
} addr_req;
-static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void finish_resolve(void* arg, grpc_error* error) {
addr_req* r = static_cast<addr_req*>(arg);
if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) {
@@ -395,9 +394,9 @@ static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
nullptr);
*r->lb_addrs = lb_addrs;
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(r->on_done, GRPC_ERROR_NONE);
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done,
+ GRPC_CLOSURE_SCHED(r->on_done,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Resolution failed", &error, 1));
}
@@ -406,8 +405,7 @@ static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
gpr_free(r);
}
-void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+void my_resolve_address(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addresses) {
@@ -417,22 +415,24 @@ void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
r->addrs = addresses;
r->lb_addrs = nullptr;
grpc_timer_init(
- exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &r->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
}
-grpc_ares_request* my_dns_lookup_ares(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb,
- char** service_config_json) {
+grpc_ares_request* my_dns_lookup_ares(const char* dns_server, const char* addr,
+ const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs,
+ bool check_grpclb,
+ char** service_config_json) {
addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r)));
r->addr = gpr_strdup(addr);
r->on_done = on_done;
r->addrs = nullptr;
r->lb_addrs = lb_addrs;
grpc_timer_init(
- exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &r->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
return nullptr;
}
@@ -442,12 +442,12 @@ grpc_ares_request* my_dns_lookup_ares(
// defined in tcp_client_posix.c
extern "C" void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx* exec_ctx, grpc_closure* closure, grpc_endpoint** ep,
+ grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
const grpc_resolved_address* addr, grpc_millis deadline);
-static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_endpoint** ep, gpr_timespec deadline);
+static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
+ gpr_timespec deadline);
typedef struct {
grpc_timer timer;
@@ -456,11 +456,11 @@ typedef struct {
gpr_timespec deadline;
} future_connect;
-static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void do_connect(void* arg, grpc_error* error) {
future_connect* fc = static_cast<future_connect*>(arg);
if (error != GRPC_ERROR_NONE) {
*fc->ep = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(fc->closure, GRPC_ERROR_REF(error));
} else if (g_server != nullptr) {
grpc_endpoint* client;
grpc_endpoint* server;
@@ -468,25 +468,23 @@ static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
*fc->ep = client;
grpc_transport* transport =
- grpc_create_chttp2_transport(exec_ctx, nullptr, server, 0);
- grpc_server_setup_transport(exec_ctx, g_server, transport, nullptr,
- nullptr);
- grpc_chttp2_transport_start_reading(exec_ctx, transport, nullptr);
+ grpc_create_chttp2_transport(nullptr, server, 0);
+ grpc_server_setup_transport(g_server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
- GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(fc->closure, GRPC_ERROR_NONE);
} else {
- sched_connect(exec_ctx, fc->closure, fc->ep, fc->deadline);
+ sched_connect(fc->closure, fc->ep, fc->deadline);
}
gpr_free(fc);
}
-static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_endpoint** ep, gpr_timespec deadline) {
+static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
+ gpr_timespec deadline) {
if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) {
*ep = nullptr;
- GRPC_CLOSURE_SCHED(
- exec_ctx, closure,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connect deadline exceeded"));
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Connect deadline exceeded"));
return;
}
@@ -495,17 +493,16 @@ static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
fc->ep = ep;
fc->deadline = deadline;
grpc_timer_init(
- exec_ctx, &fc->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &fc->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx));
}
-static void my_tcp_client_connect(grpc_exec_ctx* exec_ctx,
- grpc_closure* closure, grpc_endpoint** ep,
+static void my_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_millis deadline) {
- sched_connect(exec_ctx, closure, ep,
+ sched_connect(closure, ep,
grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC));
}
@@ -751,9 +748,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_init();
grpc_timer_manager_set_threading(false);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_executor_set_threading(false);
}
grpc_resolve_address = my_resolve_address;
grpc_dns_lookup_ares = my_dns_lookup_ares;
@@ -846,9 +842,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
g_channel = grpc_insecure_channel_create(target_uri, args, nullptr);
GPR_ASSERT(g_channel != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
gpr_free(target_uri);
gpr_free(target);
@@ -874,9 +869,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
g_server = grpc_server_create(args, nullptr);
GPR_ASSERT(g_server != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
grpc_server_register_completion_queue(g_server, cq, nullptr);
grpc_server_start(g_server);
@@ -1205,9 +1199,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_secure_channel_create(creds, target_uri, args, nullptr);
GPR_ASSERT(g_channel != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
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 ebc8c2780d..1298dd4e4f 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.cc
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -43,22 +43,22 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
if (leak_check) grpc_memory_counters_init();
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_executor_set_threading(false);
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("client_fuzzer");
grpc_endpoint* mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, nullptr, mock_endpoint, 1);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
+ grpc_create_chttp2_transport(nullptr, mock_endpoint, 1);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
grpc_channel* channel = grpc_channel_create(
- &exec_ctx, "test-target", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ "test-target", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, transport);
grpc_slice host = grpc_slice_from_static_string("localhost");
grpc_call* call = grpc_channel_create_call(
channel, nullptr, 0, cq, grpc_slice_from_static_string("/foo"), &host,
@@ -107,12 +107,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
GPR_ASSERT(GRPC_CALL_OK == error);
grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char*)data, size));
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
grpc_event ev;
while (1) {
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
switch (ev.type) {
diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc
index fb6477b579..2cb6c984c5 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.cc
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -41,17 +41,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
if (leak_check) grpc_memory_counters_init();
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_executor_set_threading(false);
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("server_fuzzer");
grpc_endpoint* mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char*)data, size));
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
grpc_server* server = grpc_server_create(nullptr, nullptr);
grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
@@ -61,9 +60,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// grpc_server_register_method(server, "/reg", NULL, 0);
grpc_server_start(server);
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, nullptr, mock_endpoint, 0);
- grpc_server_setup_transport(&exec_ctx, server, transport, nullptr, nullptr);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
+ grpc_create_chttp2_transport(nullptr, mock_endpoint, 0);
+ grpc_server_setup_transport(server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
grpc_call* call1 = nullptr;
grpc_call_details call_details1;
@@ -79,7 +78,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_event ev;
while (1) {
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
switch (ev.type) {
diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc
index 2d0db967c3..94cfbdda7e 100644
--- a/test/core/end2end/goaway_server_test.cc
+++ b/test/core/end2end/goaway_server_test.cc
@@ -39,16 +39,15 @@ static void* tag(intptr_t i) { return (void*)i; }
static gpr_mu g_mu;
static int g_resolve_port = -1;
-static void (*iomgr_resolve_address)(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+static void (*iomgr_resolve_address)(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addresses);
static grpc_ares_request* (*iomgr_dns_lookup_ares)(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** addresses, bool check_grpclb,
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addresses, bool check_grpclb,
char** service_config_json);
static void set_resolve_port(int port) {
@@ -57,14 +56,13 @@ static void set_resolve_port(int port) {
gpr_mu_unlock(&g_mu);
}
-static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+static void my_resolve_address(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {
if (0 != strcmp(addr, "test")) {
- iomgr_resolve_address(exec_ctx, addr, default_port, interested_parties,
- on_done, addrs);
+ iomgr_resolve_address(addr, default_port, interested_parties, on_done,
+ addrs);
return;
}
@@ -86,16 +84,16 @@ static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
(*addrs)->addrs[0].len = sizeof(*sa);
gpr_mu_unlock(&g_mu);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
}
static grpc_ares_request* my_dns_lookup_ares(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb,
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs, bool check_grpclb,
char** service_config_json) {
if (0 != strcmp(addr, "test")) {
- return iomgr_dns_lookup_ares(exec_ctx, dns_server, addr, default_port,
+ return iomgr_dns_lookup_ares(dns_server, addr, default_port,
interested_parties, on_done, lb_addrs,
check_grpclb, service_config_json);
}
@@ -117,7 +115,7 @@ static grpc_ares_request* my_dns_lookup_ares(
gpr_free(sa);
gpr_mu_unlock(&g_mu);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
return nullptr;
}
diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc
index 9a98c07158..177731669e 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -181,9 +181,8 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype;
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); \
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); \
{ \
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; \
- grpc_channel_args_destroy(&exec_ctx, new_client_args); \
- grpc_exec_ctx_finish(&exec_ctx); \
+ grpc_core::ExecCtx _local_exec_ctx; \
+ grpc_channel_args_destroy(new_client_args); \
} \
}
diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc
index 83439d71d2..5ce45b4c61 100644
--- a/test/core/end2end/tests/cancel_after_accept.cc
+++ b/test/core/end2end/tests/cancel_after_accept.cc
@@ -245,9 +245,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_call_unref(s);
if (args != nullptr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
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 ddcec67de5..9bd92b06e3 100644
--- a/test/core/end2end/tests/cancel_after_round_trip.cc
+++ b/test/core/end2end/tests/cancel_after_round_trip.cc
@@ -278,9 +278,8 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
grpc_call_unref(s);
if (args != nullptr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
cq_verifier_destroy(cqv);
diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc
index a8ea0ff2e0..93a06c9dfc 100644
--- a/test/core/end2end/tests/compressed_payload.cc
+++ b/test/core/end2end/tests/compressed_payload.cc
@@ -129,10 +129,9 @@ static void request_for_disabled_algorithm(
server_args =
grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_NONE);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
server_args = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &server_args, algorithm_to_disable, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ &server_args, algorithm_to_disable, false);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -257,10 +256,9 @@ static void request_for_disabled_algorithm(
grpc_byte_buffer_destroy(request_payload_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -539,10 +537,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
diff --git a/test/core/end2end/tests/filter_call_init_fails.cc b/test/core/end2end/tests/filter_call_init_fails.cc
index 6eed68a2f9..8f46f0bb91 100644
--- a/test/core/end2end/tests/filter_call_init_fails.cc
+++ b/test/core/end2end/tests/filter_call_init_fails.cc
@@ -399,26 +399,23 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) {
* Test filter - always fails to initialize a call
*/
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("access denied"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_PERMISSION_DENIED);
}
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_filter = {
grpc_call_next_op,
@@ -437,8 +434,7 @@ static const grpc_channel_filter test_filter = {
* Registration
*/
-static bool maybe_add_server_channel_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_server_channel_filter(grpc_channel_stack_builder* builder,
void* arg) {
if (g_enable_server_channel_filter) {
// Want to add the filter as close to the end as possible, to make
@@ -457,8 +453,7 @@ static bool maybe_add_server_channel_filter(grpc_exec_ctx* exec_ctx,
}
}
-static bool maybe_add_client_channel_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_client_channel_filter(grpc_channel_stack_builder* builder,
void* arg) {
if (g_enable_client_channel_filter) {
// Want to add the filter as close to the end as possible, to make
@@ -478,7 +473,7 @@ static bool maybe_add_client_channel_filter(grpc_exec_ctx* exec_ctx,
}
static bool maybe_add_client_subchannel_filter(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_stack_builder* builder, void* arg) {
if (g_enable_client_subchannel_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
diff --git a/test/core/end2end/tests/filter_causes_close.cc b/test/core/end2end/tests/filter_causes_close.cc
index 793f590686..ec8f9dbe00 100644
--- a/test/core/end2end/tests/filter_causes_close.cc
+++ b/test/core/end2end/tests/filter_causes_close.cc
@@ -197,12 +197,11 @@ typedef struct {
uint8_t unused;
} channel_data;
-static void recv_im_ready(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void recv_im_ready(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
GRPC_CLOSURE_RUN(
- exec_ctx, calld->recv_im_ready,
+ calld->recv_im_ready,
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failure that's not preventable.", &error, 1),
GRPC_ERROR_INT_GRPC_STATUS,
@@ -210,8 +209,7 @@ static void recv_im_ready(grpc_exec_ctx* exec_ctx, void* arg,
}
static void start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
call_data* calld = (call_data*)elem->call_data;
if (op->recv_initial_metadata) {
calld->recv_im_ready =
@@ -219,27 +217,24 @@ static void start_transport_stream_op_batch(
op->payload->recv_initial_metadata.recv_initial_metadata_ready =
GRPC_CLOSURE_CREATE(recv_im_ready, elem, grpc_schedule_on_exec_ctx);
}
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_filter = {
start_transport_stream_op_batch,
@@ -258,8 +253,7 @@ static const grpc_channel_filter test_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
if (g_enable_filter) {
return grpc_channel_stack_builder_prepend_filter(builder, &test_filter,
nullptr, nullptr);
diff --git a/test/core/end2end/tests/filter_latency.cc b/test/core/end2end/tests/filter_latency.cc
index c4d96ebfe2..845cbc01cf 100644
--- a/test/core/end2end/tests/filter_latency.cc
+++ b/test/core/end2end/tests/filter_latency.cc
@@ -247,14 +247,12 @@ static void test_request(grpc_end2end_test_config config) {
* Test latency filter
*/
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void client_destroy_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void client_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
gpr_mu_lock(&g_mu);
@@ -262,8 +260,7 @@ static void client_destroy_call_elem(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&g_mu);
}
-static void server_destroy_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void server_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
gpr_mu_lock(&g_mu);
@@ -271,14 +268,12 @@ static void server_destroy_call_elem(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&g_mu);
}
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_client_filter = {
grpc_call_next_op,
@@ -310,8 +305,7 @@ static const grpc_channel_filter test_server_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
grpc_channel_filter* filter = (grpc_channel_filter*)arg;
if (g_enable_filter) {
// Want to add the filter as close to the end as possible, to make
diff --git a/test/core/end2end/tests/load_reporting_hook.cc b/test/core/end2end/tests/load_reporting_hook.cc
index faabec34cb..13e3af7ac5 100644
--- a/test/core/end2end/tests/load_reporting_hook.cc
+++ b/test/core/end2end/tests/load_reporting_hook.cc
@@ -300,9 +300,8 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) {
&trailing_lr_metadata);
end_test(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, lr_server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(lr_server_args);
}
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 f1ac27fa7c..06243be75b 100644
--- a/test/core/end2end/tests/max_message_length.cc
+++ b/test/core/end2end/tests/max_message_length.cc
@@ -173,12 +173,9 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
f = begin_test(config, "test_max_request_message_length", client_args,
server_args);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (client_args != nullptr)
- grpc_channel_args_destroy(&exec_ctx, client_args);
- if (server_args != nullptr)
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ if (client_args != nullptr) grpc_channel_args_destroy(client_args);
+ if (server_args != nullptr) grpc_channel_args_destroy(server_args);
}
cqv = cq_verifier_create(f.cq);
@@ -366,12 +363,9 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
f = begin_test(config, "test_max_response_message_length", client_args,
server_args);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (client_args != nullptr)
- grpc_channel_args_destroy(&exec_ctx, client_args);
- if (server_args != nullptr)
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ if (client_args != nullptr) grpc_channel_args_destroy(client_args);
+ if (server_args != nullptr) grpc_channel_args_destroy(server_args);
}
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 d73346468a..4f09df25db 100644
--- a/test/core/end2end/tests/stream_compression_compressed_payload.cc
+++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc
@@ -129,10 +129,9 @@ static void request_for_disabled_algorithm(
server_args = grpc_channel_args_set_stream_compression_algorithm(
nullptr, GRPC_STREAM_COMPRESS_NONE);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
server_args = grpc_channel_args_stream_compression_algorithm_set_state(
- &exec_ctx, &server_args, algorithm_to_disable, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ &server_args, algorithm_to_disable, false);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -258,10 +257,9 @@ static void request_for_disabled_algorithm(
grpc_byte_buffer_destroy(request_payload_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -547,10 +545,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc
index 924961ea55..6a8c9cdcb2 100644
--- a/test/core/end2end/tests/stream_compression_payload.cc
+++ b/test/core/end2end/tests/stream_compression_payload.cc
@@ -277,10 +277,9 @@ static void test_invoke_request_response_with_payload(
end_test(&f);
config.tear_down_data(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
}
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 d3b526f04e..3e1a532af5 100644
--- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
+++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
@@ -275,10 +275,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
end_test(&f);
config.tear_down_data(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
}
diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc
index bc4d5079d8..8c5c9e834f 100644
--- a/test/core/end2end/tests/workaround_cronet_compression.cc
+++ b/test/core/end2end/tests/workaround_cronet_compression.cc
@@ -142,15 +142,14 @@ static void request_with_payload_template(
nullptr, default_server_channel_compression_algorithm);
if (user_agent_override) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args* client_args_old = client_args;
grpc_arg arg;
arg.key = const_cast<char*>(GRPC_ARG_PRIMARY_USER_AGENT_STRING);
arg.type = GRPC_ARG_STRING;
arg.value.string = user_agent_override;
client_args = grpc_channel_args_copy_and_add(client_args_old, &arg, 1);
- grpc_channel_args_destroy(&exec_ctx, client_args_old);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(client_args_old);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -351,10 +350,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
diff --git a/test/core/handshake/readahead_handshaker_server_ssl.cc b/test/core/handshake/readahead_handshaker_server_ssl.cc
index 2810082837..f271200b7b 100644
--- a/test/core/handshake/readahead_handshaker_server_ssl.cc
+++ b/test/core/handshake/readahead_handshaker_server_ssl.cc
@@ -49,41 +49,41 @@
* to the security_handshaker). This test is meant to protect code relying on
* this functionality that lives outside of this repo. */
-static void readahead_handshaker_destroy(grpc_exec_ctx* ctx,
+static void readahead_handshaker_destroy(
grpc_handshaker* handshaker) {
gpr_free(handshaker);
}
-static void readahead_handshaker_shutdown(grpc_exec_ctx* ctx,
+static void readahead_handshaker_shutdown(
grpc_handshaker* handshaker,
grpc_error* error) {}
static void readahead_handshaker_do_handshake(
- grpc_exec_ctx* ctx, grpc_handshaker* handshaker,
+ grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor, grpc_closure* on_handshake_done,
grpc_handshaker_args* args) {
- grpc_endpoint_read(ctx, args->endpoint, args->read_buffer, on_handshake_done);
+ grpc_endpoint_read(args->endpoint, args->read_buffer, on_handshake_done);
}
const grpc_handshaker_vtable readahead_handshaker_vtable = {
readahead_handshaker_destroy, readahead_handshaker_shutdown,
readahead_handshaker_do_handshake};
-static grpc_handshaker* readahead_handshaker_create(grpc_exec_ctx* ctx) {
+static grpc_handshaker* readahead_handshaker_create() {
grpc_handshaker* h = (grpc_handshaker*)gpr_zalloc(sizeof(grpc_handshaker));
grpc_handshaker_init(&readahead_handshaker_vtable, h);
return h;
}
static void readahead_handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* hf,
+ grpc_handshaker_factory* hf,
const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(handshake_mgr,
- readahead_handshaker_create(exec_ctx));
+ readahead_handshaker_create());
}
static void readahead_handshaker_factory_destroy(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory) {}
+ grpc_handshaker_factory* handshaker_factory) {}
static const grpc_handshaker_factory_vtable
readahead_handshaker_factory_vtable = {
diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc
index 81e9374819..d354ad3570 100644
--- a/test/core/http/httpcli_test.cc
+++ b/test/core/http/httpcli_test.cc
@@ -40,7 +40,7 @@ static grpc_millis n_seconds_time(int seconds) {
grpc_timeout_seconds_to_deadline(seconds));
}
-static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_finish(void* arg, grpc_error* error) {
const char* expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
@@ -53,15 +53,14 @@ static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
g_done = 1;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&g_pops),
- nullptr)));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&g_pops), nullptr)));
gpr_mu_unlock(g_mu);
}
static void test_get(int port) {
grpc_httpcli_request req;
char* host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_get");
@@ -78,19 +77,18 @@ static void test_get(int port) {
memset(&response, 0, sizeof(response));
grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get");
grpc_httpcli_get(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, n_seconds_time(1))));
+ "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(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -101,7 +99,7 @@ static void test_get(int port) {
static void test_post(int port) {
grpc_httpcli_request req;
char* host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_post");
@@ -118,20 +116,18 @@ static void test_post(int port) {
memset(&response, 0, sizeof(response));
grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post");
grpc_httpcli_post(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5,
- n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, n_seconds_time(1))));
+ "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(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -139,14 +135,14 @@ static void test_post(int port) {
grpc_http_response_destroy(&response);
}
-static void destroy_pops(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(
- static_cast<grpc_polling_entity*>(p)));
+static void destroy_pops(void* p, grpc_error* error) {
+ grpc_pollset_destroy(
+ grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p)));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_subprocess* server;
char* me = argv[0];
char* lslash = strrchr(me, '/');
@@ -196,12 +192,11 @@ int main(int argc, char** argv) {
test_get(port);
test_post(port);
- grpc_httpcli_context_destroy(&exec_ctx, &g_context);
+ grpc_httpcli_context_destroy(&g_context);
GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);
+
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 da8405c049..76bbd2d366 100644
--- a/test/core/http/httpscli_test.cc
+++ b/test/core/http/httpscli_test.cc
@@ -40,7 +40,7 @@ static grpc_millis n_seconds_time(int seconds) {
grpc_timeout_seconds_to_deadline(seconds));
}
-static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_finish(void* arg, grpc_error* error) {
const char* expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
@@ -53,15 +53,14 @@ static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
g_done = 1;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&g_pops),
- nullptr)));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&g_pops), nullptr)));
gpr_mu_unlock(g_mu);
}
static void test_get(int port) {
grpc_httpcli_request req;
char* host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_get");
@@ -79,19 +78,18 @@ static void test_get(int port) {
memset(&response, 0, sizeof(response));
grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get");
grpc_httpcli_get(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, n_seconds_time(1))));
+ "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(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -102,7 +100,7 @@ static void test_get(int port) {
static void test_post(int port) {
grpc_httpcli_request req;
char* host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_post");
@@ -120,20 +118,18 @@ static void test_post(int port) {
memset(&response, 0, sizeof(response));
grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post");
grpc_httpcli_post(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5,
- n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, n_seconds_time(1))));
+ "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(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -141,14 +137,14 @@ static void test_post(int port) {
grpc_http_response_destroy(&response);
}
-static void destroy_pops(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(
- static_cast<grpc_polling_entity*>(p)));
+static void destroy_pops(void* p, grpc_error* error) {
+ grpc_pollset_destroy(
+ grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p)));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_subprocess* server;
char* me = argv[0];
char* lslash = strrchr(me, '/');
@@ -199,12 +195,11 @@ int main(int argc, char** argv) {
test_get(port);
test_post(port);
- grpc_httpcli_context_destroy(&exec_ctx, &g_context);
+ grpc_httpcli_context_destroy(&g_context);
GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);
+
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 146a6bd553..faa5c3dcbc 100644
--- a/test/core/iomgr/combiner_test.cc
+++ b/test/core/iomgr/combiner_test.cc
@@ -28,13 +28,11 @@
static void test_no_op(void) {
gpr_log(GPR_DEBUG, "test_no_op");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, grpc_combiner_create(), "test_no_op");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_COMBINER_UNREF(grpc_combiner_create(), "test_no_op");
}
-static void set_event_to_true(grpc_exec_ctx* exec_ctx, void* value,
- grpc_error* error) {
+static void set_event_to_true(void* value, grpc_error* error) {
gpr_event_set(static_cast<gpr_event*>(value), (void*)1);
}
@@ -44,16 +42,14 @@ static void test_execute_one(void) {
grpc_combiner* lock = grpc_combiner_create();
gpr_event done;
gpr_event_init(&done);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(set_event_to_true, &done,
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &done,
grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&done, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_one");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(lock, "test_execute_one");
}
typedef struct {
@@ -67,7 +63,7 @@ typedef struct {
size_t value;
} ex_args;
-static void check_one(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) {
+static void check_one(void* a, grpc_error* error) {
ex_args* args = static_cast<ex_args*>(a);
GPR_ASSERT(*args->ctr == args->value - 1);
*args->ctr = args->value;
@@ -76,28 +72,25 @@ static void check_one(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) {
static void execute_many_loop(void* a) {
thd_args* args = static_cast<thd_args*>(a);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
size_t n = 1;
for (size_t i = 0; i < 10; i++) {
for (size_t j = 0; j < 10000; j++) {
ex_args* c = static_cast<ex_args*>(gpr_malloc(sizeof(*c)));
c->ctr = &args->ctr;
c->value = n++;
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(
check_one, c, grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
// sleep for a little bit, to test a combiner draining and another thread
// picking it up
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100));
}
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(set_event_to_true, &args->done,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &args->done,
grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_execute_many(void) {
@@ -119,20 +112,18 @@ static void test_execute_many(void) {
gpr_inf_future(GPR_CLOCK_REALTIME)) != nullptr);
gpr_thd_join(thds[i]);
}
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_many");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_COMBINER_UNREF(lock, "test_execute_many");
}
static gpr_event got_in_finally;
-static void in_finally(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void in_finally(void* arg, grpc_error* error) {
gpr_event_set(&got_in_finally, (void*)1);
}
-static void add_finally(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_CREATE(in_finally, arg,
+static void add_finally(void* arg, grpc_error* error) {
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(in_finally, arg,
grpc_combiner_finally_scheduler(
static_cast<grpc_combiner*>(arg))),
GRPC_ERROR_NONE);
@@ -142,17 +133,15 @@ static void test_execute_finally(void) {
gpr_log(GPR_DEBUG, "test_execute_finally");
grpc_combiner* lock = grpc_combiner_create();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_event_init(&got_in_finally);
GRPC_CLOSURE_SCHED(
- &exec_ctx,
GRPC_CLOSURE_CREATE(add_finally, lock, grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&got_in_finally,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_finally");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(lock, "test_execute_finally");
}
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 30a0cb5924..658971b9fb 100644
--- a/test/core/iomgr/endpoint_pair_test.cc
+++ b/test/core/iomgr/endpoint_pair_test.cc
@@ -32,7 +32,7 @@ static void clean_up(void) {}
static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
size_t slice_size) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_test_fixture f;
grpc_arg a[1];
a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
@@ -43,9 +43,8 @@ static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
f.client_ep = p.client;
f.server_ep = p.server;
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
return f;
}
@@ -54,14 +53,13 @@ static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_endpoint_pair, clean_up},
};
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
@@ -69,8 +67,8 @@ int main(int argc, char** argv) {
grpc_endpoint_tests(configs[0], g_pollset, g_mu);
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc
index 026e34105d..c011ab96d9 100644
--- a/test/core/iomgr/endpoint_tests.cc
+++ b/test/core/iomgr/endpoint_tests.cc
@@ -115,8 +115,7 @@ struct read_and_write_test_state {
grpc_closure done_write;
};
-static void read_and_write_test_read_handler(grpc_exec_ctx* exec_ctx,
- void* data, grpc_error* error) {
+static void read_and_write_test_read_handler(void* data, grpc_error* error) {
struct read_and_write_test_state* state =
(struct read_and_write_test_state*)data;
@@ -126,17 +125,14 @@ static void read_and_write_test_read_handler(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_INFO, "Read handler done");
gpr_mu_lock(g_mu);
state->read_done = 1 + (error == GRPC_ERROR_NONE);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr));
gpr_mu_unlock(g_mu);
} else if (error == GRPC_ERROR_NONE) {
- grpc_endpoint_read(exec_ctx, state->read_ep, &state->incoming,
- &state->done_read);
+ grpc_endpoint_read(state->read_ep, &state->incoming, &state->done_read);
}
}
-static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx,
- void* data, grpc_error* error) {
+static void read_and_write_test_write_handler(void* data, grpc_error* error) {
struct read_and_write_test_state* state =
(struct read_and_write_test_state*)data;
grpc_slice* slices = nullptr;
@@ -153,7 +149,7 @@ static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx,
&state->current_write_data);
grpc_slice_buffer_reset_and_unref(&state->outgoing);
grpc_slice_buffer_addn(&state->outgoing, slices, nslices);
- grpc_endpoint_write(exec_ctx, state->write_ep, &state->outgoing,
+ grpc_endpoint_write(state->write_ep, &state->outgoing,
&state->done_write);
gpr_free(slices);
return;
@@ -163,8 +159,7 @@ static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_INFO, "Write handler done");
gpr_mu_lock(g_mu);
state->write_done = 1 + (error == GRPC_ERROR_NONE);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr));
gpr_mu_unlock(g_mu);
}
@@ -178,7 +173,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
struct read_and_write_test_state state;
grpc_endpoint_test_fixture f =
begin_test(config, "read_and_write_test", slice_size);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
gpr_log(GPR_DEBUG,
@@ -217,66 +212,57 @@ static void read_and_write_test(grpc_endpoint_test_config config,
for the first iteration as for later iterations. It does the right thing
even when bytes_written is unsigned. */
state.bytes_written -= state.current_write_size;
- read_and_write_test_write_handler(&exec_ctx, &state, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ read_and_write_test_write_handler(&state, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_endpoint_read(&exec_ctx, state.read_ep, &state.incoming,
- &state.done_read);
+ grpc_endpoint_read(state.read_ep, &state.incoming, &state.done_read);
if (shutdown) {
gpr_log(GPR_DEBUG, "shutdown read");
grpc_endpoint_shutdown(
- &exec_ctx, state.read_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ state.read_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
gpr_log(GPR_DEBUG, "shutdown write");
grpc_endpoint_shutdown(
- &exec_ctx, state.write_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ state.write_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
while (!state.read_done || !state.write_done) {
grpc_pollset_worker* worker = nullptr;
- GPR_ASSERT(grpc_exec_ctx_now(&exec_ctx) < deadline);
+ GPR_ASSERT(grpc_core::ExecCtx::Get()->Now() < deadline);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
end_test(config);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.outgoing);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, state.read_ep);
- grpc_endpoint_destroy(&exec_ctx, state.write_ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ 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);
}
-static void inc_on_failure(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void inc_on_failure(void* arg, grpc_error* error) {
gpr_mu_lock(g_mu);
*(int*)arg += (error != GRPC_ERROR_NONE);
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void wait_for_fail_count(grpc_exec_ctx* exec_ctx, int* fail_count,
- int want_fail_count) {
- grpc_exec_ctx_flush(exec_ctx);
+static void wait_for_fail_count(int* fail_count, int want_fail_count) {
+ grpc_core::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(exec_ctx) < deadline &&
+ while (grpc_core::ExecCtx::Get()->Now() < deadline &&
*fail_count < want_fail_count) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(*fail_count == want_fail_count);
@@ -291,33 +277,32 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) {
grpc_slice_buffer slice_buffer;
grpc_slice_buffer_init(&slice_buffer);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_read(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 0);
- grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
+ wait_for_fail_count(&fail_count, 0);
+ grpc_endpoint_shutdown(f.client_ep,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- wait_for_fail_count(&exec_ctx, &fail_count, 1);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
+ wait_for_fail_count(&fail_count, 1);
+ grpc_endpoint_read(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 2);
+ wait_for_fail_count(&fail_count, 2);
grpc_slice_buffer_add(&slice_buffer, grpc_slice_from_copied_string("a"));
- grpc_endpoint_write(&exec_ctx, f.client_ep, &slice_buffer,
+ grpc_endpoint_write(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 3);
- grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
+ wait_for_fail_count(&fail_count, 3);
+ grpc_endpoint_shutdown(f.client_ep,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- wait_for_fail_count(&exec_ctx, &fail_count, 3);
+ wait_for_fail_count(&fail_count, 3);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &slice_buffer);
+ grpc_slice_buffer_destroy_internal(&slice_buffer);
- grpc_endpoint_destroy(&exec_ctx, f.client_ep);
- grpc_endpoint_destroy(&exec_ctx, f.server_ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_destroy(f.client_ep);
+ grpc_endpoint_destroy(f.server_ep);
}
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 ac8b2f43d1..ae77834401 100644
--- a/test/core/iomgr/ev_epollsig_linux_test.cc
+++ b/test/core/iomgr/ev_epollsig_linux_test.cc
@@ -70,19 +70,18 @@ static void test_fd_init(test_fd* tfds, int* fds, int num_fds) {
}
}
-static void test_fd_cleanup(grpc_exec_ctx* exec_ctx, test_fd* tfds,
- int num_fds) {
+static void test_fd_cleanup(test_fd* tfds, int num_fds) {
int release_fd;
int i;
for (i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(exec_ctx, tfds[i].fd,
+ grpc_fd_shutdown(tfds[i].fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_fd_cleanup"));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_fd_orphan(exec_ctx, tfds[i].fd, nullptr, &release_fd,
- false /* already_closed */, "test_fd_cleanup");
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */,
+ "test_fd_cleanup");
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(release_fd == tfds[i].inner_fd);
close(tfds[i].inner_fd);
@@ -98,22 +97,20 @@ static void test_pollset_init(test_pollset* pollsets, int num_pollsets) {
}
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
-static void test_pollset_cleanup(grpc_exec_ctx* exec_ctx,
- test_pollset* pollsets, int num_pollsets) {
+static void test_pollset_cleanup(test_pollset* pollsets, int num_pollsets) {
grpc_closure destroyed;
int i;
for (i = 0; i < num_pollsets; i++) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, pollsets[i].pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, pollsets[i].pollset, &destroyed);
+ grpc_pollset_shutdown(pollsets[i].pollset, &destroyed);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(pollsets[i].pollset);
}
}
@@ -133,7 +130,7 @@ static void test_pollset_cleanup(grpc_exec_ctx* exec_ctx,
#define NUM_POLLSETS 4
static void test_add_fd_to_pollset() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
test_fd tfds[NUM_FDS];
int fds[NUM_FDS];
test_pollset pollsets[NUM_POLLSETS];
@@ -170,33 +167,33 @@ static void test_add_fd_to_pollset() {
/* == Step 1 == */
for (i = 0; i <= 2; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[0].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
for (i = 3; i <= 4; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[1].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
for (i = 5; i <= 7; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[2].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* == Step 2 == */
for (i = 0; i <= 1; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[3].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[3].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* == Step 3 == */
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].pollset, tfds[0].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[1].pollset, tfds[0].fd);
+ grpc_core::ExecCtx::Get()->Flush();
/* == Step 4 == */
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].pollset, tfds[3].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[2].pollset, tfds[3].fd);
+ grpc_core::ExecCtx::Get()->Flush();
/* All polling islands are merged at this point */
@@ -213,9 +210,8 @@ static void test_add_fd_to_pollset() {
expected_pi, grpc_pollset_get_polling_island(pollsets[i].pollset)));
}
- test_fd_cleanup(&exec_ctx, tfds, NUM_FDS);
- test_pollset_cleanup(&exec_ctx, pollsets, NUM_POLLSETS);
- grpc_exec_ctx_finish(&exec_ctx);
+ test_fd_cleanup(tfds, NUM_FDS);
+ test_pollset_cleanup(pollsets, NUM_POLLSETS);
}
#undef NUM_FDS
@@ -235,26 +231,24 @@ static __thread int thread_wakeups = 0;
static void test_threading_loop(void* arg) {
threading_shared* shared = static_cast<threading_shared*>(arg);
while (thread_wakeups < 1000000) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker;
gpr_mu_lock(shared->mu);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, shared->pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)));
+ "pollset_work",
+ grpc_pollset_work(shared->pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(shared->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
-static void test_threading_wakeup(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void test_threading_wakeup(void* arg, grpc_error* error) {
threading_shared* shared = static_cast<threading_shared*>(arg);
++shared->wakeups;
++thread_wakeups;
if (error == GRPC_ERROR_NONE) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"consume_wakeup", grpc_wakeup_fd_consume_wakeup(shared->wakeup_fd)));
- grpc_fd_notify_on_read(exec_ctx, shared->wakeup_desc, &shared->on_wakeup);
+ grpc_fd_notify_on_read(shared->wakeup_desc, &shared->on_wakeup);
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_next",
grpc_wakeup_fd_wakeup(shared->wakeup_fd)));
}
@@ -277,13 +271,12 @@ static void test_threading(void) {
shared.wakeup_desc = grpc_fd_create(fd.read_fd, "wakeup");
shared.wakeups = 0;
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_add_fd(&exec_ctx, shared.pollset, shared.wakeup_desc);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_pollset_add_fd(shared.pollset, shared.wakeup_desc);
grpc_fd_notify_on_read(
- &exec_ctx, shared.wakeup_desc,
+ shared.wakeup_desc,
GRPC_CLOSURE_INIT(&shared.on_wakeup, test_threading_wakeup, &shared,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
}
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_first",
grpc_wakeup_fd_wakeup(shared.wakeup_fd)));
@@ -293,14 +286,13 @@ static void test_threading(void) {
fd.read_fd = 0;
grpc_wakeup_fd_destroy(&fd);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_fd_shutdown(&exec_ctx, shared.wakeup_desc, GRPC_ERROR_CANCELLED);
- grpc_fd_orphan(&exec_ctx, shared.wakeup_desc, nullptr, nullptr,
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_fd_shutdown(shared.wakeup_desc, GRPC_ERROR_CANCELLED);
+ grpc_fd_orphan(shared.wakeup_desc, nullptr, nullptr,
false /* already_closed */, "done");
- grpc_pollset_shutdown(&exec_ctx, shared.pollset,
+ grpc_pollset_shutdown(shared.pollset,
GRPC_CLOSURE_CREATE(destroy_pollset, shared.pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
}
gpr_free(shared.pollset);
}
@@ -309,7 +301,7 @@ int main(int argc, char** argv) {
const char* poll_strategy = nullptr;
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
poll_strategy = grpc_get_poll_strategy_name();
if (poll_strategy != nullptr && strcmp(poll_strategy, "epollsig") == 0) {
@@ -322,7 +314,6 @@ int main(int argc, char** argv) {
poll_strategy);
}
- grpc_exec_ctx_finish(&exec_ctx);
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 f46430c611..11e664d8ff 100644
--- a/test/core/iomgr/fd_conservation_posix_test.cc
+++ b/test/core/iomgr/fd_conservation_posix_test.cc
@@ -31,7 +31,7 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* set max # of file descriptors to a low value, and
verify we can create and destroy many more than this number
@@ -42,15 +42,14 @@ int main(int argc, char** argv) {
grpc_resource_quota_create("fd_conservation_posix_test");
for (i = 0; i < 100; i++) {
- p = grpc_iomgr_create_endpoint_pair("test", nullptr);
- grpc_endpoint_destroy(&exec_ctx, p.client);
- grpc_endpoint_destroy(&exec_ctx, p.server);
- grpc_exec_ctx_flush(&exec_ctx);
+ p = grpc_iomgr_create_endpoint_pair("test", NULL);
+ grpc_endpoint_destroy(p.client);
+ grpc_endpoint_destroy(p.server);
+ grpc_core::ExecCtx::Get()->Flush();
}
grpc_resource_quota_unref(resource_quota);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc
index a03d841ecd..3a9d801169 100644
--- a/test/core/iomgr/fd_posix_test.cc
+++ b/test/core/iomgr/fd_posix_test.cc
@@ -111,20 +111,19 @@ typedef struct {
/* Called when an upload session can be safely shutdown.
Close session FD and start to shutdown listen FD. */
-static void session_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
+static void session_shutdown_cb(void* arg, /*session */
bool success) {
session* se = static_cast<session*>(arg);
server* sv = se->sv;
- grpc_fd_orphan(exec_ctx, se->em_fd, nullptr, nullptr,
- false /* already_closed */, "a");
+ grpc_fd_orphan(se->em_fd, nullptr, nullptr, false /* already_closed */, "a");
gpr_free(se);
/* Start to shutdown listen fd. */
- grpc_fd_shutdown(exec_ctx, sv->em_fd,
+ grpc_fd_shutdown(sv->em_fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("session_shutdown_cb"));
}
/* Called when data become readable in a session. */
-static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
+static void session_read_cb(void* arg, /*session */
grpc_error* error) {
session* se = static_cast<session*>(arg);
int fd = grpc_fd_wrapped_fd(se->em_fd);
@@ -133,7 +132,7 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
ssize_t read_total = 0;
if (error != GRPC_ERROR_NONE) {
- session_shutdown_cb(exec_ctx, arg, 1);
+ session_shutdown_cb(arg, 1);
return;
}
@@ -148,7 +147,7 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
It is possible to read nothing due to spurious edge event or data has
been drained, In such a case, read() returns -1 and set errno to EAGAIN. */
if (read_once == 0) {
- session_shutdown_cb(exec_ctx, arg, 1);
+ session_shutdown_cb(arg, 1);
} else if (read_once == -1) {
if (errno == EAGAIN) {
/* An edge triggered event is cached in the kernel until next poll.
@@ -159,7 +158,7 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
TODO(chenw): in multi-threaded version, callback and polling can be
run in different threads. polling may catch a persist read edge event
before notify_on_read is called. */
- grpc_fd_notify_on_read(exec_ctx, se->em_fd, &se->session_read_closure);
+ grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
} else {
gpr_log(GPR_ERROR, "Unhandled read error %s", strerror(errno));
abort();
@@ -169,22 +168,20 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
/* Called when the listen FD can be safely shutdown.
Close listen FD and signal that server can be shutdown. */
-static void listen_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg /*server */,
- int success) {
+static void listen_shutdown_cb(void* arg /*server */, int success) {
server* sv = static_cast<server*>(arg);
- grpc_fd_orphan(exec_ctx, sv->em_fd, nullptr, nullptr,
- false /* already_closed */, "b");
+ grpc_fd_orphan(sv->em_fd, nullptr, nullptr, false /* already_closed */, "b");
gpr_mu_lock(g_mu);
sv->done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
/* Called when a new TCP connection request arrives in the listening port. */
-static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/
+static void listen_cb(void* arg, /*=sv_arg*/
grpc_error* error) {
server* sv = static_cast<server*>(arg);
int fd;
@@ -195,7 +192,7 @@ static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/
grpc_fd* listen_em_fd = sv->em_fd;
if (error != GRPC_ERROR_NONE) {
- listen_shutdown_cb(exec_ctx, arg, 1);
+ listen_shutdown_cb(arg, 1);
return;
}
@@ -207,12 +204,12 @@ static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/
se = static_cast<session*>(gpr_malloc(sizeof(*se)));
se->sv = sv;
se->em_fd = grpc_fd_create(fd, "listener");
- grpc_pollset_add_fd(exec_ctx, g_pollset, se->em_fd);
+ grpc_pollset_add_fd(g_pollset, se->em_fd);
GRPC_CLOSURE_INIT(&se->session_read_closure, session_read_cb, se,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, se->em_fd, &se->session_read_closure);
+ grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
- grpc_fd_notify_on_read(exec_ctx, listen_em_fd, &sv->listen_closure);
+ grpc_fd_notify_on_read(listen_em_fd, &sv->listen_closure);
}
/* Max number of connections pending to be accepted by listen(). */
@@ -222,7 +219,7 @@ static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/
listen_cb() is registered to be interested in reading from listen_fd.
When connection request arrives, listen_cb() is called to accept the
connection request. */
-static int server_start(grpc_exec_ctx* exec_ctx, server* sv) {
+static int server_start(server* sv) {
int port = 0;
int fd;
struct sockaddr_in sin;
@@ -236,11 +233,11 @@ static int server_start(grpc_exec_ctx* exec_ctx, server* sv) {
GPR_ASSERT(listen(fd, MAX_NUM_FD) == 0);
sv->em_fd = grpc_fd_create(fd, "server");
- grpc_pollset_add_fd(exec_ctx, g_pollset, sv->em_fd);
+ grpc_pollset_add_fd(g_pollset, sv->em_fd);
/* Register to be interested in reading from listen_fd. */
GRPC_CLOSURE_INIT(&sv->listen_closure, listen_cb, sv,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sv->em_fd, &sv->listen_closure);
+ grpc_fd_notify_on_read(sv->em_fd, &sv->listen_closure);
return port;
}
@@ -249,13 +246,13 @@ static int server_start(grpc_exec_ctx* exec_ctx, server* sv) {
static void server_wait_and_shutdown(server* sv) {
gpr_mu_lock(g_mu);
while (!sv->done) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -289,18 +286,16 @@ static void client_init(client* cl) {
}
/* Called when a client upload session is ready to shutdown. */
-static void client_session_shutdown_cb(grpc_exec_ctx* exec_ctx,
- void* arg /*client */, int success) {
+static void client_session_shutdown_cb(void* arg /*client */, int success) {
client* cl = static_cast<client*>(arg);
- grpc_fd_orphan(exec_ctx, cl->em_fd, nullptr, nullptr,
- false /* already_closed */, "c");
+ grpc_fd_orphan(cl->em_fd, nullptr, nullptr, false /* already_closed */, "c");
cl->done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
}
/* Write as much as possible, then register notify_on_write. */
-static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */
+static void client_session_write(void* arg, /*client */
grpc_error* error) {
client* cl = static_cast<client*>(arg);
int fd = grpc_fd_wrapped_fd(cl->em_fd);
@@ -308,7 +303,7 @@ static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */
if (error != GRPC_ERROR_NONE) {
gpr_mu_lock(g_mu);
- client_session_shutdown_cb(exec_ctx, arg, 1);
+ client_session_shutdown_cb(arg, 1);
gpr_mu_unlock(g_mu);
return;
}
@@ -323,10 +318,10 @@ static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */
if (cl->client_write_cnt < CLIENT_TOTAL_WRITE_CNT) {
GRPC_CLOSURE_INIT(&cl->write_closure, client_session_write, cl,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_write(exec_ctx, cl->em_fd, &cl->write_closure);
+ grpc_fd_notify_on_write(cl->em_fd, &cl->write_closure);
cl->client_write_cnt++;
} else {
- client_session_shutdown_cb(exec_ctx, arg, 1);
+ client_session_shutdown_cb(arg, 1);
}
gpr_mu_unlock(g_mu);
} else {
@@ -336,7 +331,7 @@ static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */
}
/* Start a client to send a stream of bytes. */
-static void client_start(grpc_exec_ctx* exec_ctx, client* cl, int port) {
+static void client_start(client* cl, int port) {
int fd;
struct sockaddr_in sin;
create_test_socket(port, &fd, &sin);
@@ -357,9 +352,9 @@ static void client_start(grpc_exec_ctx* exec_ctx, client* cl, int port) {
}
cl->em_fd = grpc_fd_create(fd, "client");
- grpc_pollset_add_fd(exec_ctx, g_pollset, cl->em_fd);
+ grpc_pollset_add_fd(g_pollset, cl->em_fd);
- client_session_write(exec_ctx, cl, GRPC_ERROR_NONE);
+ client_session_write(cl, GRPC_ERROR_NONE);
}
/* Wait for the signal to shutdown a client. */
@@ -367,12 +362,12 @@ static void client_wait_and_shutdown(client* cl) {
gpr_mu_lock(g_mu);
while (!cl->done) {
grpc_pollset_worker* worker = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -385,13 +380,13 @@ static void test_grpc_fd(void) {
server sv;
client cl;
int port;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
server_init(&sv);
- port = server_start(&exec_ctx, &sv);
+ port = server_start(&sv);
client_init(&cl);
- client_start(&exec_ctx, &cl, port);
- grpc_exec_ctx_finish(&exec_ctx);
+ client_start(&cl, port);
+
client_wait_and_shutdown(&cl);
server_wait_and_shutdown(&sv);
GPR_ASSERT(sv.read_bytes_total == cl.write_bytes_total);
@@ -406,27 +401,25 @@ void init_change_data(fd_change_data* fdc) { fdc->cb_that_ran = nullptr; }
void destroy_change_data(fd_change_data* fdc) {}
-static void first_read_callback(grpc_exec_ctx* exec_ctx,
- void* arg /* fd_change_data */,
+static void first_read_callback(void* arg /* fd_change_data */,
grpc_error* error) {
fd_change_data* fdc = static_cast<fd_change_data*>(arg);
gpr_mu_lock(g_mu);
fdc->cb_that_ran = first_read_callback;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void second_read_callback(grpc_exec_ctx* exec_ctx,
- void* arg /* fd_change_data */,
+static void second_read_callback(void* arg /* fd_change_data */,
grpc_error* error) {
fd_change_data* fdc = static_cast<fd_change_data*>(arg);
gpr_mu_lock(g_mu);
fdc->cb_that_ran = second_read_callback;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -443,7 +436,7 @@ static void test_grpc_fd_change(void) {
ssize_t result;
grpc_closure first_closure;
grpc_closure second_closure;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_CLOSURE_INIT(&first_closure, first_read_callback, &a,
grpc_schedule_on_exec_ctx);
@@ -460,10 +453,10 @@ static void test_grpc_fd_change(void) {
GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
em_fd = grpc_fd_create(sv[0], "test_grpc_fd_change");
- grpc_pollset_add_fd(&exec_ctx, g_pollset, em_fd);
+ grpc_pollset_add_fd(g_pollset, em_fd);
/* Register the first callback, then make its FD readable */
- grpc_fd_notify_on_read(&exec_ctx, em_fd, &first_closure);
+ grpc_fd_notify_on_read(em_fd, &first_closure);
data = 0;
result = write(sv[1], &data, 1);
GPR_ASSERT(result == 1);
@@ -473,10 +466,10 @@ static void test_grpc_fd_change(void) {
while (a.cb_that_ran == nullptr) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(a.cb_that_ran == first_read_callback);
@@ -488,7 +481,7 @@ static void test_grpc_fd_change(void) {
/* Now register a second callback with distinct change data, and do the same
thing again. */
- grpc_fd_notify_on_read(&exec_ctx, em_fd, &second_closure);
+ grpc_fd_notify_on_read(em_fd, &second_closure);
data = 0;
result = write(sv[1], &data, 1);
GPR_ASSERT(result == 1);
@@ -497,32 +490,30 @@ static void test_grpc_fd_change(void) {
while (b.cb_that_ran == nullptr) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
/* Except now we verify that second_read_callback ran instead */
GPR_ASSERT(b.cb_that_ran == second_read_callback);
gpr_mu_unlock(g_mu);
- grpc_fd_orphan(&exec_ctx, em_fd, nullptr, nullptr, false /* already_closed */,
- "d");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_fd_orphan(em_fd, nullptr, nullptr, false /* already_closed */, "d");
+
destroy_change_data(&a);
destroy_change_data(&b);
close(sv[1]);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
@@ -531,10 +522,10 @@ int main(int argc, char** argv) {
test_grpc_fd_change();
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc
index 719eab91fe..502b40f2cf 100644
--- a/test/core/iomgr/pollset_set_test.cc
+++ b/test/core/iomgr/pollset_set_test.cc
@@ -47,11 +47,10 @@ void init_test_pollset_sets(test_pollset_set* pollset_sets, const int num_pss) {
}
}
-void cleanup_test_pollset_sets(grpc_exec_ctx* exec_ctx,
- test_pollset_set* pollset_sets,
+void cleanup_test_pollset_sets(test_pollset_set* pollset_sets,
const int num_pss) {
for (int i = 0; i < num_pss; i++) {
- grpc_pollset_set_destroy(exec_ctx, pollset_sets[i].pss);
+ grpc_pollset_set_destroy(pollset_sets[i].pss);
pollset_sets[i].pss = nullptr;
}
}
@@ -73,21 +72,19 @@ static void init_test_pollsets(test_pollset* pollsets, const int num_pollsets) {
}
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-static void cleanup_test_pollsets(grpc_exec_ctx* exec_ctx,
- test_pollset* pollsets,
+static void cleanup_test_pollsets(test_pollset* pollsets,
const int num_pollsets) {
grpc_closure destroyed;
for (int i = 0; i < num_pollsets; i++) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, pollsets[i].ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, pollsets[i].ps, &destroyed);
+ grpc_pollset_shutdown(pollsets[i].ps, &destroyed);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(pollsets[i].ps);
pollsets[i].ps = nullptr;
}
@@ -105,45 +102,43 @@ typedef struct test_fd {
grpc_closure on_readable; /* Closure to call when this fd is readable */
} test_fd;
-void on_readable(grpc_exec_ctx* exec_ctx, void* tfd, grpc_error* error) {
+void on_readable(void* tfd, grpc_error* error) {
((test_fd*)tfd)->is_on_readable_called = true;
}
-static void reset_test_fd(grpc_exec_ctx* exec_ctx, test_fd* tfd) {
+static void reset_test_fd(test_fd* tfd) {
tfd->is_on_readable_called = false;
GRPC_CLOSURE_INIT(&tfd->on_readable, on_readable, tfd,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable);
+ grpc_fd_notify_on_read(tfd->fd, &tfd->on_readable);
}
-static void init_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds,
- const int num_fds) {
+static void init_test_fds(test_fd* tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd));
tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd),
"test_fd");
- reset_test_fd(exec_ctx, &tfds[i]);
+ reset_test_fd(&tfds[i]);
}
}
-static void cleanup_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds,
- const int num_fds) {
+static void cleanup_test_fds(test_fd* tfds, const int num_fds) {
int release_fd;
for (int i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(exec_ctx, tfds[i].fd,
+ grpc_fd_shutdown(tfds[i].fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("fd cleanup"));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::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
* grpc_wakeup_fd and we would like to destroy it ourselves (by calling
* grpc_wakeup_fd_destroy). To prevent grpc_fd from calling close() on the
* underlying fd, call it with a non-NULL 'release_fd' parameter */
- grpc_fd_orphan(exec_ctx, tfds[i].fd, nullptr, &release_fd,
- false /* already_closed */, "test_fd_cleanup");
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */,
+ "test_fd_cleanup");
+ grpc_core::ExecCtx::Get()->Flush();
grpc_wakeup_fd_destroy(&tfds[i].wakeup_fd);
}
@@ -155,8 +150,7 @@ static void make_test_fds_readable(test_fd* tfds, const int num_fds) {
}
}
-static void verify_readable_and_reset(grpc_exec_ctx* exec_ctx, test_fd* tfds,
- const int num_fds) {
+static void verify_readable_and_reset(test_fd* tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
/* Verify that the on_readable callback was called */
GPR_ASSERT(tfds[i].is_on_readable_called);
@@ -164,7 +158,7 @@ static void verify_readable_and_reset(grpc_exec_ctx* exec_ctx, test_fd* tfds,
/* Reset the tfd[i] structure */
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_wakeup_fd_consume_wakeup(&tfds[i].wakeup_fd));
- reset_test_fd(exec_ctx, &tfds[i]);
+ reset_test_fd(&tfds[i]);
}
}
@@ -205,7 +199,7 @@ static void pollset_set_test_basic() {
* |
* +---> FD9 (Added after PS2 is added to PSS0)
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker;
grpc_millis deadline;
@@ -216,34 +210,33 @@ static void pollset_set_test_basic() {
const int num_ps = GPR_ARRAY_SIZE(pollsets);
const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(pollsets, num_ps);
init_test_pollset_sets(pollset_sets, num_pss);
/* Construct the pollset_set/pollset/fd tree (see diagram above) */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[2].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[3].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[4].fd);
+ grpc_pollset_add_fd(pollsets[0].ps, tfds[2].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[3].fd);
+ grpc_pollset_add_fd(pollsets[2].ps, tfds[4].fd);
- grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
+ grpc_pollset_set_add_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[1].pss, pollsets[0].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[0].pss, pollsets[1].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[0].pss, pollsets[2].ps);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[5].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[6].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[7].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[8].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[9].fd);
+ grpc_pollset_add_fd(pollsets[0].ps, tfds[7].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[8].fd);
+ grpc_pollset_add_fd(pollsets[2].ps, tfds[9].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::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
@@ -263,34 +256,32 @@ static void pollset_set_test_basic() {
deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker, deadline));
+ grpc_pollset_work(pollsets[i].ps, &worker, deadline));
gpr_mu_unlock(pollsets[i].mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* Test tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd);
- grpc_exec_ctx_flush(&exec_ctx);
-
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps);
-
- grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, pollsets, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, pollset_sets, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
+ 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_core::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_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(pollsets, num_ps);
+ cleanup_test_pollset_sets(pollset_sets, num_pss);
}
/* Same FD added multiple times to the pollset_set tree */
@@ -310,7 +301,7 @@ void pollset_set_test_dup_fds() {
* | +--> FD2
* +---> FD1
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker;
grpc_millis deadline;
@@ -321,21 +312,20 @@ void pollset_set_test_dup_fds() {
const int num_ps = 1;
const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(&pollset, num_ps);
init_test_pollset_sets(pollset_sets, num_pss);
/* Construct the structure */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[2].fd);
+ grpc_pollset_add_fd(pollset.ps, tfds[1].fd);
+ grpc_pollset_add_fd(pollset.ps, tfds[2].fd);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps);
- grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
+ grpc_pollset_set_add_pollset(pollset_sets[1].pss, pollset.ps);
+ grpc_pollset_set_add_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
/* Test. Make all FDs readable and make sure that can be observed by doing a
* grpc_pollset_work on the pollset 'PS' */
@@ -345,27 +335,25 @@ void pollset_set_test_dup_fds() {
deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollset.ps, &worker, deadline));
+ grpc_pollset_work(pollset.ps, &worker, deadline));
gpr_mu_unlock(pollset.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
/* Tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
-
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps);
- grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, &pollset, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, pollset_sets, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[1].fd);
+
+ 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_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(&pollset, num_ps);
+ cleanup_test_pollset_sets(pollset_sets, num_pss);
}
/* Pollset_set with an empty pollset */
@@ -383,7 +371,7 @@ void pollset_set_test_empty_pollset() {
* |
* +---> FD2
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker;
grpc_millis deadline;
@@ -394,17 +382,17 @@ void pollset_set_test_empty_pollset() {
const int num_ps = GPR_ARRAY_SIZE(pollsets);
const int num_pss = 1;
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(pollsets, num_ps);
init_test_pollset_sets(&pollset_set, num_pss);
/* Construct the structure */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_set.pss, tfds[0].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[2].fd);
+ grpc_pollset_set_add_fd(pollset_set.pss, tfds[0].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[1].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[2].fd);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps);
+ grpc_pollset_set_add_pollset(pollset_set.pss, pollsets[0].ps);
+ grpc_pollset_set_add_pollset(pollset_set.pss, pollsets[1].ps);
/* Test. Make all FDs readable and make sure that can be observed by doing
* grpc_pollset_work on the empty pollset 'PS0' */
@@ -414,27 +402,26 @@ void pollset_set_test_empty_pollset() {
deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker, deadline));
+ grpc_pollset_work(pollsets[0].ps, &worker, deadline));
gpr_mu_unlock(pollsets[0].mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
/* Tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_set.pss, tfds[0].fd);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, pollsets, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, &pollset_set, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ 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_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(pollsets, num_ps);
+ cleanup_test_pollset_sets(&pollset_set, num_pss);
}
int main(int argc, char** argv) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
const char* poll_strategy = grpc_get_poll_strategy_name();
@@ -452,7 +439,6 @@ int main(int argc, char** argv) {
poll_strategy);
}
- grpc_exec_ctx_finish(&exec_ctx);
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 1a5eb9ace1..6fb6f72a00 100644
--- a/test/core/iomgr/resolve_address_posix_test.cc
+++ b/test/core/iomgr/resolve_address_posix_test.cc
@@ -46,29 +46,29 @@ typedef struct args_struct {
grpc_pollset_set* pollset_set;
} args_struct;
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
-void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) {
+void args_init(args_struct* args) {
gpr_event_init(&args->ev);
args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(args->pollset, &args->mu);
args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
args->addrs = nullptr;
}
-void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) {
+void args_finish(args_struct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
grpc_resolved_addresses_destroy(args->addrs);
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
grpc_closure do_nothing_cb;
GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
+ grpc_pollset_shutdown(args->pollset, &do_nothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
}
@@ -79,26 +79,24 @@ static grpc_millis n_sec_deadline(int seconds) {
static void actually_poll(void* argsp) {
args_struct* args = static_cast<args_struct*>(argsp);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline = n_sec_deadline(10);
while (true) {
bool done = gpr_atm_acq_load(&args->done_atm) != 0;
if (done) {
break;
}
- grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx);
+ grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
- n_sec_deadline(1)));
+ 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(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
gpr_event_set(&args->ev, (void*)1);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void poll_pollset_until_request_done(args_struct* args) {
@@ -107,8 +105,7 @@ static void poll_pollset_until_request_done(args_struct* args) {
gpr_thd_new(&id, actually_poll, args, nullptr);
}
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp,
- grpc_error* err) {
+static void must_succeed(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err == GRPC_ERROR_NONE);
GPR_ASSERT(args->addrs != nullptr);
@@ -116,29 +113,28 @@ static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp,
gpr_atm_rel_store(&args->done_atm, 1);
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) {
+static void must_fail(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err != GRPC_ERROR_NONE);
gpr_atm_rel_store(&args->done_atm, 1);
}
static void test_unix_socket(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
poll_pollset_until_request_done(&args);
grpc_resolve_address(
- &exec_ctx, "unix:/path/name", nullptr, args.pollset_set,
+ "unix:/path/name", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_unix_socket_path_name_too_long(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
const char prefix[] = "unix:/path/name";
size_t path_name_length =
GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) + 6;
@@ -150,22 +146,21 @@ static void test_unix_socket_path_name_too_long(void) {
poll_pollset_until_request_done(&args);
grpc_resolve_address(
- &exec_ctx, path_name, nullptr, args.pollset_set,
+ path_name, nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
gpr_free(path_name);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
test_unix_socket();
test_unix_socket_path_name_too_long();
- grpc_executor_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_executor_shutdown();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc
index 1c5aa38a95..e44d660dad 100644
--- a/test/core/iomgr/resolve_address_test.cc
+++ b/test/core/iomgr/resolve_address_test.cc
@@ -39,32 +39,32 @@ typedef struct args_struct {
grpc_pollset_set* pollset_set;
} args_struct;
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
-void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) {
+void args_init(args_struct* args) {
gpr_event_init(&args->ev);
args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(args->pollset, &args->mu);
args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
args->addrs = nullptr;
gpr_atm_rel_store(&args->done_atm, 0);
}
-void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) {
+void args_finish(args_struct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
grpc_resolved_addresses_destroy(args->addrs);
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
grpc_closure do_nothing_cb;
GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
gpr_mu_lock(args->mu);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
+ 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(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
}
@@ -74,119 +74,109 @@ static grpc_millis n_sec_deadline(int seconds) {
}
static void poll_pollset_until_request_done(args_struct* args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline = n_sec_deadline(10);
while (true) {
bool done = gpr_atm_acq_load(&args->done_atm) != 0;
if (done) {
break;
}
- grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx);
+ grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
- n_sec_deadline(1)));
+ 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(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
gpr_event_set(&args->ev, (void*)1);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp,
- grpc_error* err) {
+static void must_succeed(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err == GRPC_ERROR_NONE);
GPR_ASSERT(args->addrs != nullptr);
GPR_ASSERT(args->addrs->naddrs > 0);
gpr_atm_rel_store(&args->done_atm, 1);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) {
+static void must_fail(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err != GRPC_ERROR_NONE);
gpr_atm_rel_store(&args->done_atm, 1);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
static void test_localhost(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "localhost:1", nullptr, args.pollset_set,
+ "localhost:1", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "localhost", "1", args.pollset_set,
+ "localhost", "1", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_non_numeric_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "localhost", "https", args.pollset_set,
+ "localhost", "https", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_missing_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "localhost", nullptr, args.pollset_set,
+ "localhost", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_ipv6_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "[2001:db8::1]:1", nullptr, args.pollset_set,
+ "[2001:db8::1]:1", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_ipv6_without_port(void) {
@@ -197,17 +187,16 @@ static void test_ipv6_without_port(void) {
};
unsigned i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, kCases[i], "80", args.pollset_set,
+ kCases[i], "80", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
}
@@ -218,17 +207,16 @@ static void test_invalid_ip_addresses(void) {
};
unsigned i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, kCases[i], nullptr, args.pollset_set,
+ kCases[i], nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
}
@@ -238,24 +226,23 @@ static void test_unparseable_hostports(void) {
};
unsigned i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, kCases[i], "1", args.pollset_set,
+ kCases[i], "1", args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
}
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
test_localhost();
test_default_port();
test_non_numeric_default_port();
@@ -264,8 +251,8 @@ int main(int argc, char** argv) {
test_ipv6_without_port();
test_invalid_ip_addresses();
test_unparseable_hostports();
- grpc_executor_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_executor_shutdown();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc
index 6851702e67..b44e8ce1be 100644
--- a/test/core/iomgr/resource_quota_test.cc
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -27,7 +27,7 @@
gpr_mu g_mu;
gpr_cv g_cv;
-static void inc_int_cb(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) {
+static void inc_int_cb(void* a, grpc_error* error) {
gpr_mu_lock(&g_mu);
++*(int*)a;
gpr_cv_signal(&g_cv);
@@ -43,7 +43,7 @@ static void assert_counter_becomes(int* ctr, int value) {
gpr_mu_unlock(&g_mu);
}
-static void set_event_cb(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) {
+static void set_event_cb(void* a, grpc_error* error) {
gpr_event_set((gpr_event*)a, (void*)1);
}
grpc_closure* set_event(gpr_event* ev) {
@@ -56,13 +56,12 @@ typedef struct {
grpc_closure* then;
} reclaimer_args;
-static void reclaimer_cb(grpc_exec_ctx* exec_ctx, void* args,
- grpc_error* error) {
+static void reclaimer_cb(void* args, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
reclaimer_args* a = static_cast<reclaimer_args*>(args);
- grpc_resource_user_free(exec_ctx, a->resource_user, a->size);
- grpc_resource_user_finish_reclamation(exec_ctx, a->resource_user);
- GRPC_CLOSURE_RUN(exec_ctx, a->then, GRPC_ERROR_NONE);
+ grpc_resource_user_free(a->resource_user, a->size);
+ grpc_resource_user_finish_reclamation(a->resource_user);
+ GRPC_CLOSURE_RUN(a->then, GRPC_ERROR_NONE);
gpr_free(a);
}
@@ -75,10 +74,9 @@ grpc_closure* make_reclaimer(grpc_resource_user* resource_user, size_t size,
return GRPC_CLOSURE_CREATE(reclaimer_cb, a, grpc_schedule_on_exec_ctx);
}
-static void unused_reclaimer_cb(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void unused_reclaimer_cb(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_CANCELLED);
- GRPC_CLOSURE_RUN(exec_ctx, static_cast<grpc_closure*>(arg), GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(static_cast<grpc_closure*>(arg), GRPC_ERROR_NONE);
}
grpc_closure* make_unused_reclaimer(grpc_closure* then) {
return GRPC_CLOSURE_CREATE(unused_reclaimer_cb, then,
@@ -86,9 +84,8 @@ grpc_closure* make_unused_reclaimer(grpc_closure* then) {
}
static void destroy_user(grpc_resource_user* usr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_unref(usr);
}
static void test_no_op(void) {
@@ -120,14 +117,12 @@ static void test_instant_alloc_then_free(void) {
grpc_resource_quota_resize(q, 1024 * 1024);
grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, NULL);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -140,10 +135,9 @@ static void test_instant_alloc_free_pair(void) {
grpc_resource_quota_resize(q, 1024 * 1024);
grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, nullptr);
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, NULL);
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -158,16 +152,15 @@ static void test_simple_async_alloc(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -182,9 +175,9 @@ static void test_async_alloc_blocked_by_size(void) {
gpr_event ev;
gpr_event_init(&ev);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(
&ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr);
}
@@ -193,9 +186,8 @@ static void test_async_alloc_blocked_by_size(void) {
nullptr);
;
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -210,32 +202,30 @@ static void test_scavenge(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr1, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr1, 1024);
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -251,33 +241,32 @@ static void test_scavenge_blocked(void) {
gpr_event ev;
{
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(
&ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr1, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr1, 1024);
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -293,9 +282,9 @@ static void test_blocked_until_scheduled_reclaim(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
@@ -303,18 +292,16 @@ static void test_blocked_until_scheduled_reclaim(void) {
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_reclaimer(usr, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -322,9 +309,8 @@ static void test_blocked_until_scheduled_reclaim(void) {
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -340,9 +326,9 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
@@ -350,18 +336,16 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr1, false,
- make_reclaimer(usr1, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr1, false, make_reclaimer(usr1, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -369,9 +353,8 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -387,9 +370,9 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
@@ -397,18 +380,16 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_reclaimer(usr, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_reclaimer(usr, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -416,9 +397,8 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -435,13 +415,12 @@ static void test_unused_reclaim_is_cancelled(void) {
gpr_event destructive_done;
gpr_event_init(&destructive_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false, make_unused_reclaimer(set_event(&benign_done)));
+ usr, false, make_unused_reclaimer(set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_unused_reclaimer(set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_unused_reclaimer(set_event(&destructive_done)));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -470,22 +449,20 @@ static void test_benign_reclaim_is_preferred(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&benign_done)));
+ usr, false, make_reclaimer(usr, 1024, set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_unused_reclaimer(set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_unused_reclaimer(set_event(&destructive_done)));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -496,9 +473,9 @@ static void test_benign_reclaim_is_preferred(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
@@ -508,9 +485,8 @@ static void test_benign_reclaim_is_preferred(void) {
nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -533,22 +509,20 @@ static void test_multiple_reclaims_can_be_triggered(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 512, set_event(&benign_done)));
+ usr, false, make_reclaimer(usr, 512, set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_reclaimer(usr, 512, set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_reclaimer(usr, 512, set_event(&destructive_done)));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -559,9 +533,9 @@ static void test_multiple_reclaims_can_be_triggered(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
@@ -571,9 +545,8 @@ static void test_multiple_reclaims_can_be_triggered(void) {
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -591,20 +564,17 @@ static void test_resource_user_stays_allocated_until_memory_released(void) {
grpc_resource_quota_resize(q, 1024 * 1024);
grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, NULL);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_quota_unref(q);
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_resource_user_unref(usr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
}
@@ -624,11 +594,10 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
gpr_event reclaimer_cancelled;
gpr_event_init(&reclaimer_cancelled);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_unused_reclaimer(set_event(&reclaimer_cancelled)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_unused_reclaimer(set_event(&reclaimer_cancelled)));
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -636,27 +605,27 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline(
- 5)) != nullptr);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+
+ GPR_ASSERT(gpr_event_wait(&allocated,
+ grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_unref(usr);
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
@@ -674,9 +643,9 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+
GPR_ASSERT(gpr_event_wait(&allocated,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
}
@@ -684,11 +653,10 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
gpr_event reclaimer_done;
gpr_event_init(&reclaimer_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&reclaimer_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_reclaimer(usr, 1024, set_event(&reclaimer_done)));
+
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -696,20 +664,19 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline(
- 5)) != nullptr);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+
+ GPR_ASSERT(gpr_event_wait(&allocated,
+ grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
}
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
destroy_user(usr);
grpc_resource_quota_unref(q);
@@ -732,16 +699,15 @@ static void test_one_slice(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
destroy_user(usr);
grpc_resource_quota_unref(q);
@@ -765,23 +731,21 @@ static void test_one_slice_deleted_late(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_unref(usr);
}
grpc_resource_quota_unref(q);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
}
@@ -809,9 +773,9 @@ static void test_negative_rq_free_pool(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
@@ -822,16 +786,14 @@ static void test_negative_rq_free_pool(void) {
GPR_ASSERT(grpc_resource_quota_get_memory_pressure(q) > 1 - eps);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_unref(usr);
}
grpc_resource_quota_unref(q);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
}
diff --git a/test/core/iomgr/tcp_client_posix_test.cc b/test/core/iomgr/tcp_client_posix_test.cc
index 9fb1a2d770..12295ef180 100644
--- a/test/core/iomgr/tcp_client_posix_test.cc
+++ b/test/core/iomgr/tcp_client_posix_test.cc
@@ -53,26 +53,24 @@ static grpc_millis test_deadline(void) {
static void finish_connection() {
gpr_mu_lock(g_mu);
g_connections_complete++;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(&exec_ctx, g_pollset, nullptr)));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
+
gpr_mu_unlock(g_mu);
}
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void must_succeed(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting != nullptr);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_endpoint_shutdown(
- exec_ctx, g_connecting,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
- grpc_endpoint_destroy(exec_ctx, g_connecting);
+ grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "must_succeed called"));
+ grpc_endpoint_destroy(g_connecting);
g_connecting = nullptr;
finish_connection();
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void must_fail(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting == nullptr);
GPR_ASSERT(error != GRPC_ERROR_NONE);
finish_connection();
@@ -85,7 +83,7 @@ void test_succeeds(void) {
int r;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_succeeds");
@@ -108,8 +106,8 @@ void test_succeeds(void) {
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr,
(socklen_t*)&resolved_addr.len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set,
- nullptr, &resolved_addr, GRPC_MILLIS_INF_FUTURE);
+ grpc_tcp_client_connect(&done, &g_connecting, g_pollset_set, nullptr,
+ &resolved_addr, GRPC_MILLIS_INF_FUTURE);
/* await the connection */
do {
@@ -125,17 +123,15 @@ void test_succeeds(void) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
+ grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
void test_fails(void) {
@@ -143,7 +139,7 @@ void test_fails(void) {
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_fails");
@@ -157,8 +153,8 @@ void test_fails(void) {
/* connect to a broken address */
GRPC_CLOSURE_INIT(&done, must_fail, nullptr, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set,
- nullptr, &resolved_addr, GRPC_MILLIS_INF_FUTURE);
+ grpc_tcp_client_connect(&done, &g_connecting, g_pollset_set, nullptr,
+ &resolved_addr, GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
@@ -166,7 +162,7 @@ void test_fails(void) {
while (g_connections_complete == connections_complete_before) {
grpc_pollset_worker* worker = nullptr;
grpc_millis polling_deadline = test_deadline();
- switch (grpc_timer_check(&exec_ctx, &polling_deadline)) {
+ switch (grpc_timer_check(&polling_deadline)) {
case GRPC_TIMERS_FIRED:
break;
case GRPC_TIMERS_NOT_CHECKED:
@@ -174,42 +170,40 @@ void test_fails(void) {
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- polling_deadline)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, polling_deadline)));
break;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset_set = grpc_pollset_set_create();
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(g_pollset, &g_mu);
- grpc_pollset_set_add_pollset(&exec_ctx, g_pollset_set, g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_add_pollset(g_pollset_set, g_pollset);
+
test_succeeds();
gpr_log(GPR_ERROR, "End of first test");
test_fails();
- grpc_pollset_set_destroy(&exec_ctx, g_pollset_set);
+ grpc_pollset_set_destroy(g_pollset_set);
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
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 101d7bf6b5..344478ea97 100644
--- a/test/core/iomgr/tcp_client_uv_test.cc
+++ b/test/core/iomgr/tcp_client_uv_test.cc
@@ -46,30 +46,28 @@ static grpc_millis test_deadline(void) {
return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
}
-static void finish_connection(grpc_exec_ctx* exec_ctx) {
+static void finish_connection() {
gpr_mu_lock(g_mu);
g_connections_complete++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL)));
gpr_mu_unlock(g_mu);
}
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void must_succeed(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting != NULL);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_endpoint_shutdown(
- exec_ctx, g_connecting,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
- grpc_endpoint_destroy(exec_ctx, g_connecting);
+ grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "must_succeed called"));
+ grpc_endpoint_destroy(g_connecting);
g_connecting = NULL;
- finish_connection(exec_ctx);
+ finish_connection();
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void must_fail(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting == NULL);
GPR_ASSERT(error != GRPC_ERROR_NONE);
- finish_connection(exec_ctx);
+ finish_connection();
}
static void close_cb(uv_handle_t* handle) { gpr_free(handle); }
@@ -89,7 +87,7 @@ void test_succeeds(void) {
uv_tcp_t* svr_handle = static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t)));
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_succeeds");
@@ -110,8 +108,8 @@ void test_succeeds(void) {
GPR_ASSERT(uv_tcp_getsockname(svr_handle, (struct sockaddr*)addr,
(int*)&resolved_addr.len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL,
- &resolved_addr, GRPC_MILLIS_INF_FUTURE);
+ grpc_tcp_client_connect(&done, &g_connecting, NULL, NULL, &resolved_addr,
+ GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
@@ -119,11 +117,11 @@ void test_succeeds(void) {
grpc_pollset_worker* worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
+ grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
@@ -131,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(&exec_ctx);
}
void test_fails(void) {
@@ -140,7 +136,7 @@ void test_fails(void) {
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_fails");
@@ -154,8 +150,8 @@ void test_fails(void) {
/* connect to a broken address */
GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL,
- &resolved_addr, GRPC_MILLIS_INF_FUTURE);
+ grpc_tcp_client_connect(&done, &g_connecting, NULL, NULL, &resolved_addr,
+ GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
@@ -164,7 +160,7 @@ void test_fails(void) {
grpc_pollset_worker* worker = NULL;
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
grpc_millis polling_deadline = test_deadline();
- switch (grpc_timer_check(&exec_ctx, &polling_deadline)) {
+ switch (grpc_timer_check(&polling_deadline)) {
case GRPC_TIMERS_FIRED:
break;
case GRPC_TIMERS_NOT_CHECKED:
@@ -172,39 +168,37 @@ void test_fails(void) {
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- polling_deadline)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, polling_deadline)));
break;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, 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(&exec_ctx);
+
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(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
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 7986dc2b19..4018fe50bd 100644
--- a/test/core/iomgr/tcp_posix_test.cc
+++ b/test/core/iomgr/tcp_posix_test.cc
@@ -131,8 +131,7 @@ static size_t count_slices(grpc_slice* slices, size_t nslices,
return num_bytes;
}
-static void read_cb(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void read_cb(void* user_data, grpc_error* error) {
struct read_socket_state* state = (struct read_socket_state*)user_data;
size_t read_bytes;
int current_data;
@@ -147,11 +146,11 @@ static void read_cb(grpc_exec_ctx* exec_ctx, void* user_data,
gpr_log(GPR_INFO, "Read %" PRIuPTR " bytes of %" PRIuPTR, read_bytes,
state->target_read_bytes);
if (state->read_bytes >= state->target_read_bytes) {
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
} else {
- grpc_endpoint_read(exec_ctx, state->ep, &state->incoming, &state->read_cb);
+ grpc_endpoint_read(state->ep, &state->incoming, &state->read_cb);
gpr_mu_unlock(g_mu);
}
}
@@ -164,7 +163,7 @@ static void read_test(size_t num_bytes, size_t slice_size) {
size_t written_bytes;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR,
num_bytes, slice_size);
@@ -175,9 +174,8 @@ static void read_test(size_t num_bytes, size_t slice_size) {
a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args,
- "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -188,24 +186,22 @@ static void read_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_endpoint_destroy(ep);
}
/* Write to a socket until it fills up, then read from it using the grpc_tcp
@@ -217,7 +213,7 @@ static void large_read_test(size_t slice_size) {
ssize_t written_bytes;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size);
@@ -228,9 +224,8 @@ static void large_read_test(size_t slice_size) {
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "large_read_test"),
- &args, "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket(sv[0]);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -241,24 +236,22 @@ static void large_read_test(size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_endpoint_destroy(ep);
}
struct write_socket_state {
@@ -289,16 +282,15 @@ static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
return slices;
}
-static void write_done(grpc_exec_ctx* exec_ctx,
- void* user_data /* write_socket_state */,
+static void write_done(void* user_data /* write_socket_state */,
grpc_error* error) {
struct write_socket_state* state = (struct write_socket_state*)user_data;
gpr_log(GPR_INFO, "Write done callback called");
gpr_mu_lock(g_mu);
gpr_log(GPR_INFO, "Signalling write done");
state->write_done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -309,7 +301,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
int flags;
int current = 0;
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
flags = fcntl(fd, F_GETFL, 0);
GPR_ASSERT(fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) == 0);
@@ -319,11 +311,11 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
gpr_mu_lock(g_mu);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
+ grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(10)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
do {
bytes_read =
read(fd, buf, bytes_left > read_size ? read_size : bytes_left);
@@ -356,7 +348,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
grpc_closure write_done_closure;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO,
"Start write test with %" PRIuPTR " bytes, slice size %" PRIuPTR,
@@ -368,9 +360,8 @@ static void write_test(size_t num_bytes, size_t slice_size) {
a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "write_test"), &args,
- "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
state.ep = ep;
state.write_done = 0;
@@ -382,7 +373,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
GRPC_CLOSURE_INIT(&write_done_closure, write_done, &state,
grpc_schedule_on_exec_ctx);
- grpc_endpoint_write(&exec_ctx, ep, &outgoing, &write_done_closure);
+ grpc_endpoint_write(ep, &outgoing, &write_done_closure);
drain_socket_blocking(sv[0], num_bytes, num_bytes);
gpr_mu_lock(g_mu);
for (;;) {
@@ -391,25 +382,23 @@ static void write_test(size_t num_bytes, size_t slice_size) {
break;
}
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing);
- grpc_endpoint_destroy(&exec_ctx, ep);
+ grpc_slice_buffer_destroy_internal(&outgoing);
+ grpc_endpoint_destroy(ep);
gpr_free(slices);
- grpc_exec_ctx_finish(&exec_ctx);
}
-void on_fd_released(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* errors) {
+void on_fd_released(void* arg, grpc_error* errors) {
int* done = (int*)arg;
*done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
}
/* Do a read_test, then release fd and try to read/write again. Verify that
@@ -422,7 +411,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
int fd;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure fd_released_cb;
int fd_released_done = 0;
GRPC_CLOSURE_INIT(&fd_released_cb, &on_fd_released, &fd_released_done,
@@ -439,10 +428,9 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args,
- "test");
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0);
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -453,38 +441,35 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
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(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_tcp_destroy_and_release_fd(&exec_ctx, ep, &fd, &fd_released_cb);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_tcp_destroy_and_release_fd(ep, &fd, &fd_released_cb);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
while (!fd_released_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_log(GPR_DEBUG, "wakeup: fd_released_done=%d", fd_released_done);
}
gpr_mu_unlock(g_mu);
GPR_ASSERT(fd_released_done == 1);
GPR_ASSERT(fd == sv[1]);
- grpc_exec_ctx_finish(&exec_ctx);
written_bytes = fill_socket_partial(sv[0], num_bytes);
drain_socket_blocking(fd, written_bytes, written_bytes);
@@ -522,7 +507,7 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
size_t slice_size) {
int sv[2];
grpc_endpoint_test_fixture f;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
create_sockets(sv);
grpc_resource_quota* resource_quota =
@@ -532,15 +517,13 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- f.client_ep = grpc_tcp_create(
- &exec_ctx, grpc_fd_create(sv[0], "fixture:client"), &args, "test");
- f.server_ep = grpc_tcp_create(
- &exec_ctx, grpc_fd_create(sv[1], "fixture:server"), &args, "test");
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, g_pollset);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ f.client_ep =
+ grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client"), &args, "test");
+ f.server_ep =
+ grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server"), &args, "test");
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
return f;
}
@@ -549,14 +532,13 @@ static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up},
};
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
@@ -565,8 +547,8 @@ int main(int argc, char** argv) {
run_tests();
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
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 48d8d425a5..ba9fe92c9c 100644
--- a/test/core/iomgr/tcp_server_posix_test.cc
+++ b/test/core/iomgr/tcp_server_posix_test.cc
@@ -110,8 +110,7 @@ static void on_connect_result_set(on_connect_result* result,
result->server, acceptor->port_index, acceptor->fd_index);
}
-static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void server_weak_ref_shutdown(void* arg, grpc_error* error) {
server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg);
weak_ref->server = nullptr;
}
@@ -145,12 +144,11 @@ static void test_addr_init_str(test_addr* addr) {
}
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
- grpc_pollset* pollset,
+static void on_connect(void* arg, grpc_endpoint* tcp, grpc_pollset* pollset,
grpc_tcp_server_acceptor* acceptor) {
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
on_connect_result temp_result;
on_connect_result_set(&temp_result, acceptor);
@@ -159,38 +157,33 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
gpr_mu_lock(g_mu);
g_result = temp_result;
g_nconnects++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
static void test_no_op(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_start");
- grpc_tcp_server_start(&exec_ctx, s, nullptr, 0, on_connect, nullptr);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(s, nullptr, 0, on_connect, nullptr);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -201,17 +194,15 @@ static void test_no_op_with_port(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port_and_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port = -1;
@@ -222,13 +213,12 @@ static void test_no_op_with_port_and_start(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_start(&exec_ctx, s, nullptr, 0, on_connect, nullptr);
+ grpc_tcp_server_start(s, nullptr, 0, on_connect, nullptr);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
-static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
+static grpc_error* tcp_connect(const test_addr* remote,
on_connect_result* result) {
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
@@ -254,17 +244,17 @@ static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
}
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before &&
- deadline > grpc_exec_ctx_now(exec_ctx)) {
+ deadline > grpc_core::ExecCtx::Get()->Now()) {
grpc_pollset_worker* worker = nullptr;
grpc_error* err;
- if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)) !=
+ if ((err = grpc_pollset_work(g_pollset, &worker, deadline)) !=
GRPC_ERROR_NONE) {
gpr_mu_unlock(g_mu);
close(clifd);
return err;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_log(GPR_DEBUG, "wait done");
@@ -279,7 +269,7 @@ static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
gpr_mu_unlock(g_mu);
gpr_log(GPR_INFO, "Result (%d, %d) fd %d", result->port_index,
result->fd_index, result->server_fd);
- grpc_tcp_server_unref(exec_ctx, result->server);
+ grpc_tcp_server_unref(result->server);
return GRPC_ERROR_NONE;
}
@@ -292,7 +282,7 @@ static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
static void test_connect(size_t num_connects,
const grpc_channel_args* channel_args,
test_addrs* dst_addrs, bool test_dst_addrs) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
grpc_resolved_address resolved_addr1;
struct sockaddr_storage* const addr =
@@ -307,7 +297,7 @@ static void test_connect(size_t num_connects,
grpc_tcp_server* s;
const unsigned num_ports = 2;
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, channel_args, &s));
+ grpc_tcp_server_create(nullptr, channel_args, &s));
unsigned port_num;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);
@@ -352,7 +342,7 @@ static void test_connect(size_t num_connects,
svr1_fd_count = grpc_tcp_server_port_fd_count(s, 1);
GPR_ASSERT(svr1_fd_count >= 1);
- grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, nullptr);
+ grpc_tcp_server_start(s, &g_pollset, 1, on_connect, nullptr);
if (dst_addrs != nullptr) {
int ports[] = {svr_port, svr1_port};
@@ -372,7 +362,7 @@ static void test_connect(size_t num_connects,
test_addr_init_str(&dst);
++num_tested;
on_connect_result_init(&result);
- if ((err = tcp_connect(&exec_ctx, &dst, &result)) == GRPC_ERROR_NONE &&
+ if ((err = tcp_connect(&dst, &result)) == GRPC_ERROR_NONE &&
result.server_fd >= 0 && result.server == s) {
continue;
}
@@ -403,8 +393,8 @@ static void test_connect(size_t num_connects,
for (connect_num = 0; connect_num < num_connects; ++connect_num) {
on_connect_result result;
on_connect_result_init(&result);
- GPR_ASSERT(GRPC_LOG_IF_ERROR("tcp_connect",
- tcp_connect(&exec_ctx, &dst, &result)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("tcp_connect", tcp_connect(&dst, &result)));
GPR_ASSERT(result.server_fd == fd);
GPR_ASSERT(result.port_index == port_num);
GPR_ASSERT(result.fd_index == fd_num);
@@ -420,21 +410,19 @@ static void test_connect(size_t num_connects,
GPR_ASSERT(weak_ref.server != nullptr);
GPR_ASSERT(grpc_tcp_server_port_fd(s, 0, 0) >= 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
/* Weak ref lost. */
GPR_ASSERT(weak_ref.server == nullptr);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_arg chan_args[1];
chan_args[0].type = GRPC_ARG_INTEGER;
chan_args[0].key = const_cast<char*>(GRPC_ARG_EXPAND_WILDCARD_ADDRS);
@@ -497,8 +485,8 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
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 dd047a0498..07b1fb1579 100644
--- a/test/core/iomgr/tcp_server_uv_test.cc
+++ b/test/core/iomgr/tcp_server_uv_test.cc
@@ -74,8 +74,7 @@ static void on_connect_result_set(on_connect_result* result,
result->fd_index = acceptor->fd_index;
}
-static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void server_weak_ref_shutdown(void* arg, grpc_error* error) {
server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg);
weak_ref->server = NULL;
}
@@ -97,12 +96,11 @@ static void server_weak_ref_set(server_weak_ref* weak_ref,
weak_ref->server = server;
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
- grpc_pollset* pollset,
+static void on_connect(void* arg, grpc_endpoint* tcp, grpc_pollset* pollset,
grpc_tcp_server_acceptor* acceptor) {
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
on_connect_result temp_result;
on_connect_result_set(&temp_result, acceptor);
@@ -111,38 +109,33 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
gpr_mu_lock(g_mu);
g_result = temp_result;
g_nconnects++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL)));
gpr_mu_unlock(g_mu);
}
static void test_no_op(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_start");
- grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -153,17 +146,15 @@ static void test_no_op_with_port(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port_and_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port;
@@ -174,10 +165,9 @@ static void test_no_op_with_port_and_start(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
+ grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
static void connect_cb(uv_connect_t* req, int status) {
@@ -187,8 +177,8 @@ static void connect_cb(uv_connect_t* req, int status) {
static void close_cb(uv_handle_t* handle) { gpr_free(handle); }
-static void tcp_connect(grpc_exec_ctx* exec_ctx, const struct sockaddr* remote,
- socklen_t remote_len, on_connect_result* result) {
+static void tcp_connect(const struct sockaddr* remote, socklen_t remote_len,
+ on_connect_result* result) {
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
uv_tcp_t* client_handle =
static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t)));
@@ -208,10 +198,10 @@ static void tcp_connect(grpc_exec_ctx* exec_ctx, const struct sockaddr* remote,
grpc_pollset_worker* worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(exec_ctx, g_pollset, &worker,
+ grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(deadline))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_log(GPR_DEBUG, "wait done");
@@ -224,7 +214,7 @@ static void tcp_connect(grpc_exec_ctx* exec_ctx, const struct sockaddr* remote,
/* Tests a tcp server with multiple ports. */
static void test_connect(unsigned n) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
grpc_resolved_address resolved_addr1;
struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
@@ -233,8 +223,7 @@ static void test_connect(unsigned n) {
int svr_port;
int svr1_port;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
unsigned i;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);
@@ -257,48 +246,45 @@ static void test_connect(unsigned n) {
GRPC_ERROR_NONE &&
svr_port == svr1_port);
- grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, NULL);
+ grpc_tcp_server_start(s, &g_pollset, 1, on_connect, NULL);
GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6*)addr1) == 0);
for (i = 0; i < n; i++) {
on_connect_result result;
on_connect_result_init(&result);
- tcp_connect(&exec_ctx, (struct sockaddr*)addr, (socklen_t)resolved_addr.len,
- &result);
+ tcp_connect((struct sockaddr*)addr, (socklen_t)resolved_addr.len, &result);
GPR_ASSERT(result.port_index == 0);
GPR_ASSERT(result.server == s);
if (weak_ref.server == NULL) {
server_weak_ref_set(&weak_ref, result.server);
}
- grpc_tcp_server_unref(&exec_ctx, result.server);
+ grpc_tcp_server_unref(result.server);
on_connect_result_init(&result);
- tcp_connect(&exec_ctx, (struct sockaddr*)addr1,
- (socklen_t)resolved_addr1.len, &result);
+ tcp_connect((struct sockaddr*)addr1, (socklen_t)resolved_addr1.len,
+ &result);
GPR_ASSERT(result.port_index == 1);
GPR_ASSERT(result.server == s);
- grpc_tcp_server_unref(&exec_ctx, result.server);
+ grpc_tcp_server_unref(result.server);
}
/* Weak ref to server valid until final unref. */
GPR_ASSERT(weak_ref.server != NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
/* Weak ref lost. */
GPR_ASSERT(weak_ref.server == NULL);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size()));
@@ -313,8 +299,8 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
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 dc965ef7dc..3041674bd7 100644
--- a/test/core/iomgr/timer_list_test.cc
+++ b/test/core/iomgr/timer_list_test.cc
@@ -36,118 +36,114 @@ extern "C" grpc_tracer_flag grpc_timer_check_trace;
static int cb_called[MAX_CB][2];
-static void cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void cb(void* arg, grpc_error* error) {
cb_called[(intptr_t)arg][error == GRPC_ERROR_NONE]++;
}
static void add_test(void) {
int i;
grpc_timer timers[20];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "add_test");
- grpc_timer_list_init(&exec_ctx);
+ grpc_timer_list_init();
grpc_timer_trace.value = 1;
grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
- grpc_millis start = grpc_exec_ctx_now(&exec_ctx);
+ grpc_millis start = grpc_core::ExecCtx::Get()->Now();
/* 10 ms timers. will expire in the current epoch */
for (i = 0; i < 10; i++) {
grpc_timer_init(
- &exec_ctx, &timers[i], start + 10,
+ &timers[i], start + 10,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx));
}
/* 1010 ms timers. will expire in the next epoch */
for (i = 10; i < 20; i++) {
grpc_timer_init(
- &exec_ctx, &timers[i], start + 1010,
+ &timers[i], start + 1010,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx));
}
/* collect timers. Only the first batch should be ready. */
- exec_ctx.now = start + 500;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 500);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+
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;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) ==
- GRPC_TIMERS_CHECKED_AND_EMPTY);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 600);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_CHECKED_AND_EMPTY);
+
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;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 1500);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+
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;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) ==
- GRPC_TIMERS_CHECKED_AND_EMPTY);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 1600);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_CHECKED_AND_EMPTY);
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
GPR_ASSERT(cb_called[i][0] == 0);
}
- grpc_timer_list_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_list_shutdown();
}
/* Cleaning up a list with pending timers. */
void destruction_test(void) {
grpc_timer timers[5];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "destruction_test");
- exec_ctx.now_is_valid = true;
- exec_ctx.now = 0;
- grpc_timer_list_init(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(0);
+ grpc_timer_list_init();
grpc_timer_trace.value = 1;
grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
grpc_timer_init(
- &exec_ctx, &timers[0], 100,
+ &timers[0], 100,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)0, grpc_schedule_on_exec_ctx));
grpc_timer_init(
- &exec_ctx, &timers[1], 3,
+ &timers[1], 3,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)1, grpc_schedule_on_exec_ctx));
grpc_timer_init(
- &exec_ctx, &timers[2], 100,
+ &timers[2], 100,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)2, grpc_schedule_on_exec_ctx));
grpc_timer_init(
- &exec_ctx, &timers[3], 3,
+ &timers[3], 3,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)3, grpc_schedule_on_exec_ctx));
grpc_timer_init(
- &exec_ctx, &timers[4], 1,
+ &timers[4], 1,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)4, grpc_schedule_on_exec_ctx));
- exec_ctx.now = 2;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(2);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+
GPR_ASSERT(1 == cb_called[4][1]);
- grpc_timer_cancel(&exec_ctx, &timers[0]);
- grpc_timer_cancel(&exec_ctx, &timers[3]);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_cancel(&timers[0]);
+ grpc_timer_cancel(&timers[3]);
+
GPR_ASSERT(1 == cb_called[0][0]);
GPR_ASSERT(1 == cb_called[3][0]);
- grpc_timer_list_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_list_shutdown();
+
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 803f017106..2c5719f4ae 100644
--- a/test/core/iomgr/udp_server_test.cc
+++ b/test/core/iomgr/udp_server_test.cc
@@ -50,7 +50,7 @@ static int g_number_of_writes = 0;
static int g_number_of_bytes_read = 0;
static int g_number_of_orphan_calls = 0;
-static void on_read(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) {
+static void on_read(grpc_fd* emfd, void* user_data) {
char read_buffer[512];
ssize_t byte_count;
@@ -61,22 +61,22 @@ static void on_read(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) {
g_number_of_reads++;
g_number_of_bytes_read += (int)byte_count;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void on_write(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) {
+static void on_write(grpc_fd* emfd, void* user_data) {
gpr_mu_lock(g_mu);
g_number_of_writes++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void on_fd_orphaned(grpc_exec_ctx* exec_ctx, grpc_fd* emfd,
- grpc_closure* closure, void* user_data) {
+static void on_fd_orphaned(grpc_fd* emfd, grpc_closure* closure,
+ void* user_data) {
gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d",
grpc_fd_wrapped_fd(emfd));
g_number_of_orphan_calls++;
@@ -127,24 +127,22 @@ static test_socket_factory* test_socket_factory_create(void) {
}
static void test_no_op(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
LOG_TEST("test_no_op_with_start");
- grpc_udp_server_start(&exec_ctx, s, nullptr, 0, nullptr);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_start(s, nullptr, 0, nullptr);
+ grpc_udp_server_destroy(s, nullptr);
}
static void test_no_op_with_port(void) {
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
@@ -156,8 +154,7 @@ static void test_no_op_with_port(void) {
GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
on_fd_orphaned));
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which should have been orphaned. */
GPR_ASSERT(g_number_of_orphan_calls == 1);
@@ -165,7 +162,7 @@ static void test_no_op_with_port(void) {
static void test_no_op_with_port_and_socket_factory(void) {
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
@@ -175,7 +172,7 @@ static void test_no_op_with_port_and_socket_factory(void) {
grpc_channel_args* channel_args =
grpc_channel_args_copy_and_add(nullptr, &socket_factory_arg, 1);
grpc_udp_server* s = grpc_udp_server_create(channel_args);
- grpc_channel_args_destroy(&exec_ctx, channel_args);
+ grpc_channel_args_destroy(channel_args);
LOG_TEST("test_no_op_with_port_and_socket_factory");
@@ -187,8 +184,8 @@ static void test_no_op_with_port_and_socket_factory(void) {
GPR_ASSERT(socket_factory->number_of_socket_calls == 1);
GPR_ASSERT(socket_factory->number_of_bind_calls == 1);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
+
grpc_socket_factory_unref(&socket_factory->base);
/* The server had a single FD, which should have been orphaned. */
@@ -197,7 +194,7 @@ static void test_no_op_with_port_and_socket_factory(void) {
static void test_no_op_with_port_and_start(void) {
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
@@ -209,10 +206,9 @@ static void test_no_op_with_port_and_start(void) {
GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
on_fd_orphaned));
- grpc_udp_server_start(&exec_ctx, s, nullptr, 0, nullptr);
+ grpc_udp_server_start(s, nullptr, 0, nullptr);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which is orphaned exactly once in *
* grpc_udp_server_destroy. */
@@ -220,7 +216,7 @@ static void test_no_op_with_port_and_start(void) {
}
static void test_receive(int number_of_clients) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
int clifd, svrfd;
@@ -248,7 +244,7 @@ static void test_receive(int number_of_clients) {
GPR_ASSERT(resolved_addr.len <= sizeof(struct sockaddr_storage));
pollsets[0] = g_pollset;
- grpc_udp_server_start(&exec_ctx, s, pollsets, 1, nullptr);
+ grpc_udp_server_start(s, pollsets, 1, nullptr);
gpr_mu_lock(g_mu);
@@ -264,13 +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(&exec_ctx)) {
+ deadline > grpc_core::ExecCtx::Get()->Now()) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(g_number_of_reads == number_of_reads_before + 1);
@@ -280,8 +275,7 @@ static void test_receive(int number_of_clients) {
gpr_mu_unlock(g_mu);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which is orphaned exactly once in *
* grpc_udp_server_destroy. */
@@ -291,14 +285,13 @@ static void test_receive(int number_of_clients) {
GPR_ASSERT(g_number_of_writes > 0);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
@@ -314,8 +307,8 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
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 64d383ad0a..7d0a24a459 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -148,41 +148,37 @@ static grpc_httpcli_response http_response(int status, const char* body) {
/* -- Tests. -- */
static void test_empty_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
GPR_ASSERT(md_array.md == nullptr);
GPR_ASSERT(md_array.size == 0);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_add_to_empty_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
const char* key = "hello";
const char* value = "there blah blah blah blah blah blah blah";
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
grpc_credentials_mdelem_array_add(&md_array, md);
GPR_ASSERT(md_array.size == 1);
GPR_ASSERT(grpc_mdelem_eq(md, md_array.md[0]));
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_add_abunch_to_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
const char* key = "hello";
const char* value = "there blah blah blah blah blah blah blah";
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
size_t num_entries = 1000;
for (size_t i = 0; i < num_entries; ++i) {
grpc_credentials_mdelem_array_add(&md_array, md);
@@ -190,57 +186,52 @@ static void test_add_abunch_to_md_array(void) {
for (size_t i = 0; i < num_entries; ++i) {
GPR_ASSERT(grpc_mdelem_eq(md_array.md[i], md));
}
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
- GRPC_CREDENTIALS_OK);
+ &response, &token_md, &token_lifetime) == GRPC_CREDENTIALS_OK);
GPR_ASSERT(token_lifetime == 3599 * GPR_MS_PER_SEC);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(token_md), "authorization") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(token_md),
"Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") ==
0);
- GRPC_MDELEM_UNREF(&exec_ctx, token_md);
+ GRPC_MDELEM_UNREF(token_md);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(401, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response = http_response(200, "");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
@@ -249,14 +240,13 @@ static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
" \"expires_in\":3599, "
" \"token_type\":\"Bearer\"");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response = http_response(200,
@@ -264,14 +254,13 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
" \"expires_in\":3599, "
" \"token_type\":\"Bearer\"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
@@ -280,15 +269,14 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
" \"expires_in\":3599, "
"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
@@ -296,10 +284,9 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
" \"token_type\":\"Bearer\"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
@@ -336,8 +323,7 @@ static void check_metadata(const expected_md* expected,
}
}
-static void check_request_metadata(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void check_request_metadata(void* arg, grpc_error* error) {
request_metadata_state* state = (request_metadata_state*)arg;
gpr_log(GPR_INFO, "expected_error: %s",
grpc_error_string(state->expected_error));
@@ -358,9 +344,8 @@ static void check_request_metadata(grpc_exec_ctx* exec_ctx, void* arg,
state->expected_size, state->md_array.size);
GPR_ASSERT(state->md_array.size == state->expected_size);
check_metadata(state->expected, &state->md_array);
- grpc_credentials_mdelem_array_destroy(exec_ctx, &state->md_array);
- grpc_pollset_set_destroy(exec_ctx,
- grpc_polling_entity_pollset_set(&state->pollent));
+ grpc_credentials_mdelem_array_destroy(&state->md_array);
+ grpc_pollset_set_destroy(grpc_polling_entity_pollset_set(&state->pollent));
gpr_free(state);
}
@@ -379,22 +364,21 @@ static request_metadata_state* make_request_metadata_state(
return state;
}
-static void run_request_metadata_test(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds,
+static void run_request_metadata_test(grpc_call_credentials* creds,
grpc_auth_metadata_context auth_md_ctx,
request_metadata_state* state) {
grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, creds, &state->pollent, auth_md_ctx, &state->md_array,
+ creds, &state->pollent, auth_md_ctx, &state->md_array,
&state->on_request_metadata, &error)) {
// Synchronous result. Invoke the callback directly.
- check_request_metadata(exec_ctx, state, error);
+ check_request_metadata(state, error);
GRPC_ERROR_UNREF(error);
}
}
static void test_google_iam_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
test_google_iam_authorization_token},
{GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
@@ -406,13 +390,12 @@ static void test_google_iam_creds(void) {
nullptr);
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
}
static void test_access_token_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {{GRPC_AUTHORIZATION_METADATA_KEY, "Bearer blah"}};
request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
@@ -421,16 +404,14 @@ static void test_access_token_creds(void) {
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
}
static grpc_security_status check_channel_oauth2_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
GPR_ASSERT(strcmp(c->type, "mock") == 0);
GPR_ASSERT(call_creds != nullptr);
GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
@@ -438,7 +419,7 @@ static grpc_security_status check_channel_oauth2_create_security_connector(
}
static void test_channel_oauth2_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
nullptr, check_channel_oauth2_create_security_connector, nullptr};
@@ -452,14 +433,13 @@ static void test_channel_oauth2_composite_creds(void) {
grpc_channel_credentials_release(channel_creds);
grpc_call_credentials_release(oauth2_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- &exec_ctx, channel_oauth2_creds, nullptr, nullptr, nullptr,
- &new_args) == GRPC_SECURITY_OK);
+ channel_oauth2_creds, nullptr, nullptr, nullptr, &new_args) ==
+ GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_google_iam_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {
{GRPC_AUTHORIZATION_METADATA_KEY, test_oauth2_bearer_token},
{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
@@ -471,15 +451,15 @@ static void test_oauth2_google_iam_composite_creds(void) {
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create(
- &exec_ctx, "authorization", test_oauth2_bearer_token, 0);
+ "authorization", test_oauth2_bearer_token, 0);
grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
nullptr);
grpc_call_credentials* composite_creds =
grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds,
nullptr);
- grpc_call_credentials_unref(&exec_ctx, oauth2_creds);
- grpc_call_credentials_unref(&exec_ctx, google_iam_creds);
+ grpc_call_credentials_unref(oauth2_creds);
+ grpc_call_credentials_unref(google_iam_creds);
GPR_ASSERT(
strcmp(composite_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0);
const grpc_call_credentials_array* creds_array =
@@ -489,17 +469,15 @@ static void test_oauth2_google_iam_composite_creds(void) {
GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
GPR_ASSERT(strcmp(creds_array->creds_array[1]->type,
GRPC_CALL_CREDENTIALS_TYPE_IAM) == 0);
- run_request_metadata_test(&exec_ctx, composite_creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, composite_creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(composite_creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(composite_creds);
}
static grpc_security_status
check_channel_oauth2_google_iam_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
const grpc_call_credentials_array* creds_array;
GPR_ASSERT(strcmp(c->type, "mock") == 0);
GPR_ASSERT(call_creds != nullptr);
@@ -514,7 +492,7 @@ check_channel_oauth2_google_iam_create_security_connector(
}
static void test_channel_oauth2_google_iam_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
nullptr, check_channel_oauth2_google_iam_create_security_connector,
@@ -538,11 +516,10 @@ static void test_channel_oauth2_google_iam_composite_creds(void) {
grpc_call_credentials_release(google_iam_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- &exec_ctx, channel_oauth2_iam_creds, nullptr, nullptr, nullptr,
+ channel_oauth2_iam_creds, nullptr, nullptr, nullptr,
&new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_iam_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_compute_engine_http_request(
@@ -559,35 +536,32 @@ static void validate_compute_engine_http_request(
}
static int compute_engine_httpcli_get_success_override(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(200, valid_oauth2_json_response);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int compute_engine_httpcli_get_failure_override(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(403, "Not Authorized.");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int httpcli_post_should_not_be_called(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body_bytes, size_t body_size, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, const char* body_bytes,
+ size_t body_size, grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
-static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
@@ -596,7 +570,7 @@ static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
}
static void test_compute_engine_creds_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
grpc_call_credentials* creds =
@@ -609,24 +583,23 @@ static void test_compute_engine_creds_success(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_compute_engine_creds_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token."),
@@ -637,10 +610,9 @@ static void test_compute_engine_creds_failure(void) {
grpc_google_compute_engine_credentials_create(nullptr);
grpc_httpcli_set_override(compute_engine_httpcli_get_failure_override,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_refresh_token_http_request(
@@ -667,27 +639,27 @@ static void validate_refresh_token_http_request(
}
static int refresh_token_httpcli_post_success(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body, size_t body_size, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, const char* body, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(200, valid_oauth2_json_response);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int refresh_token_httpcli_post_failure(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body, size_t body_size, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, const char* body, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(403, "Not Authorized.");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_refresh_token_creds_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
@@ -700,24 +672,23 @@ static void test_refresh_token_creds_success(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_success);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_refresh_token_creds_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token."),
@@ -728,10 +699,9 @@ static void test_refresh_token_creds_failure(void) {
test_refresh_token_str, nullptr);
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_failure);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_jwt_encode_and_sign_params(
@@ -821,7 +791,7 @@ static void test_jwt_creds_lifetime(void) {
static void test_jwt_creds_success(void) {
char* json_key_string = test_json_key_str();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
char* expected_md_value;
@@ -835,16 +805,16 @@ static void test_jwt_creds_success(void) {
request_metadata_state* state =
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(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_jwt_encode_and_sign_set_override(
encode_and_sign_jwt_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Third request: Different service url so jwt_encode_and_sign should be
called again (no caching). */
@@ -852,19 +822,18 @@ static void test_jwt_creds_success(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
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(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
gpr_free(json_key_string);
gpr_free(expected_md_value);
grpc_jwt_encode_and_sign_set_override(nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_jwt_creds_signing_failure(void) {
char* json_key_string = test_json_key_str();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
request_metadata_state* state = make_request_metadata_state(
@@ -875,12 +844,11 @@ static void test_jwt_creds_signing_failure(void) {
json_key_string, grpc_max_auth_token_lifetime(), nullptr);
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_failure);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
+ run_request_metadata_test(creds, auth_md_ctx, state);
gpr_free(json_key_string);
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
grpc_jwt_encode_and_sign_set_override(nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void set_google_default_creds_env_var_with_file_contents(
@@ -897,7 +865,7 @@ static void set_google_default_creds_env_var_with_file_contents(
}
static void test_google_default_creds_auth_key(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_service_account_jwt_access_credentials* jwt;
grpc_composite_channel_credentials* creds;
char* json_key = test_json_key_str();
@@ -913,13 +881,12 @@ static void test_google_default_creds_auth_key(void) {
strcmp(jwt->key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") ==
0);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
+ grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_google_default_creds_refresh_token(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_google_refresh_token_credentials* refresh;
grpc_composite_channel_credentials* creds;
grpc_flush_cached_google_default_credentials();
@@ -931,15 +898,13 @@ static void test_google_default_creds_refresh_token(void) {
refresh = (grpc_google_refresh_token_credentials*)creds->call_creds;
GPR_ASSERT(strcmp(refresh->refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
+ grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
- grpc_exec_ctx_finish(&exec_ctx);
}
static int default_creds_gce_detection_httpcli_get_success_override(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, "");
grpc_http_header* headers =
static_cast<grpc_http_header*>(gpr_malloc(sizeof(*headers) * 1));
@@ -949,14 +914,14 @@ static int default_creds_gce_detection_httpcli_get_success_override(
response->hdrs = headers;
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static char* null_well_known_creds_path_getter(void) { return nullptr; }
static void test_google_default_creds_gce(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
request_metadata_state* state =
@@ -981,8 +946,8 @@ static void test_google_default_creds_gce(void) {
GPR_ASSERT(creds->call_creds != nullptr);
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds->call_creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds->call_creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Check that we get a cached creds if we call
grpc_google_default_credentials_create again.
@@ -994,22 +959,20 @@ static void test_google_default_creds_gce(void) {
GPR_ASSERT(cached_creds == &creds->base);
/* Cleanup. */
- grpc_channel_credentials_unref(&exec_ctx, cached_creds);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
+ grpc_channel_credentials_unref(cached_creds);
+ grpc_channel_credentials_unref(&creds->base);
grpc_httpcli_set_override(nullptr, nullptr);
grpc_override_well_known_credentials_path_getter(nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static int default_creds_gce_detection_httpcli_get_failure_override(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
/* No magic header. */
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
*response = http_response(200, "");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -1093,7 +1056,7 @@ static void plugin_destroy(void* state) {
static void test_metadata_plugin_success(void) {
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
request_metadata_state* md_state = make_request_metadata_state(
@@ -1106,17 +1069,17 @@ static void test_metadata_plugin_success(void) {
grpc_call_credentials* creds =
grpc_metadata_credentials_create_from_plugin(plugin, nullptr);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
+ run_request_metadata_test(creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
}
static void test_metadata_plugin_failure(void) {
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
char* expected_error;
@@ -1134,10 +1097,10 @@ static void test_metadata_plugin_failure(void) {
grpc_call_credentials* creds =
grpc_metadata_credentials_create_from_plugin(plugin, nullptr);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
+ run_request_metadata_test(creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
}
@@ -1158,7 +1121,7 @@ static void test_get_well_known_google_credentials_file_path(void) {
}
static void test_channel_creds_duplicate_without_call_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_credentials* channel_creds =
grpc_fake_transport_security_credentials_create();
@@ -1167,23 +1130,21 @@ static void test_channel_creds_duplicate_without_call_creds(void) {
grpc_channel_credentials_duplicate_without_call_credentials(
channel_creds);
GPR_ASSERT(dup == channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, dup);
+ grpc_channel_credentials_unref(dup);
grpc_call_credentials* call_creds =
grpc_access_token_credentials_create("blah", nullptr);
grpc_channel_credentials* composite_creds =
grpc_composite_channel_credentials_create(channel_creds, call_creds,
nullptr);
- grpc_call_credentials_unref(&exec_ctx, call_creds);
+ grpc_call_credentials_unref(call_creds);
dup = grpc_channel_credentials_duplicate_without_call_credentials(
composite_creds);
GPR_ASSERT(dup == channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, dup);
-
- grpc_channel_credentials_unref(&exec_ctx, channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, composite_creds);
+ grpc_channel_credentials_unref(dup);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_credentials_unref(channel_creds);
+ grpc_channel_credentials_unref(composite_creds);
}
typedef struct {
diff --git a/test/core/security/json_token_test.cc b/test/core/security/json_token_test.cc
index 0b6ccd5e37..b717de06d9 100644
--- a/test/core/security/json_token_test.cc
+++ b/test/core/security/json_token_test.cc
@@ -207,7 +207,7 @@ static void test_parse_json_key_failure_no_private_key(void) {
static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
char** scratchpad) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
char* b64;
char* decoded;
grpc_json* json;
@@ -215,7 +215,7 @@ static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
b64 = static_cast<char*>(gpr_malloc(len + 1));
strncpy(b64, str, len);
b64[len] = '\0';
- slice = grpc_base64_decode(&exec_ctx, b64, 1);
+ slice = grpc_base64_decode(b64, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice));
decoded = static_cast<char*>(gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1));
strncpy(decoded, (const char*)GRPC_SLICE_START_PTR(slice),
@@ -225,7 +225,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(&exec_ctx);
+
return json;
}
@@ -327,12 +327,12 @@ static void check_jwt_claim(grpc_json* claim, const char* expected_audience,
static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
const char* signed_data,
size_t signed_data_size) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
EVP_MD_CTX* md_ctx = EVP_MD_CTX_create();
EVP_PKEY* key = EVP_PKEY_new();
- grpc_slice sig = grpc_base64_decode(&exec_ctx, b64_signature, 1);
+ grpc_slice sig = grpc_base64_decode(b64_signature, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
GPR_ASSERT(GRPC_SLICE_LENGTH(sig) == 128);
@@ -347,11 +347,9 @@ static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(sig),
GRPC_SLICE_LENGTH(sig)) == 1);
- grpc_slice_unref_internal(&exec_ctx, sig);
+ grpc_slice_unref_internal(sig);
if (key != nullptr) EVP_PKEY_free(key);
if (md_ctx != nullptr) EVP_MD_CTX_destroy(md_ctx);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
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 df0ebe5607..dd798ec1d1 100644
--- a/test/core/security/jwt_verifier_test.cc
+++ b/test/core/security/jwt_verifier_test.cc
@@ -209,8 +209,8 @@ static void test_claims_success(void) {
grpc_json* json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ grpc_core::ExecCtx _local_exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
@@ -219,8 +219,7 @@ static void test_claims_success(void) {
GPR_ASSERT(strcmp(grpc_jwt_claims_id(claims), "jwtuniqueid") == 0);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_OK);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_expired_claims_failure(void) {
@@ -232,8 +231,8 @@ static void test_expired_claims_failure(void) {
gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME};
GPR_ASSERT(json != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ grpc_core::ExecCtx _local_exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
@@ -246,17 +245,15 @@ 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(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_invalid_claims_failure(void) {
grpc_slice s = grpc_slice_from_copied_string(invalid_claims);
grpc_json* json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_jwt_claims_from_json(&exec_ctx, json, s) == nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == nullptr);
}
static void test_bad_audience_claims_failure(void) {
@@ -265,13 +262,12 @@ static void test_bad_audience_claims_failure(void) {
grpc_json* json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ grpc_core::ExecCtx _local_exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://bar.com") ==
GRPC_JWT_VERIFIER_BAD_AUDIENCE);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_bad_subject_claims_failure(void) {
@@ -280,13 +276,12 @@ static void test_bad_subject_claims_failure(void) {
grpc_json* json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ grpc_core::ExecCtx _local_exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_BAD_SUBJECT);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static char* json_key_str(const char* last_part) {
@@ -323,17 +318,16 @@ static grpc_httpcli_response http_response(int status, char* body) {
}
static int httpcli_post_should_not_be_called(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body_bytes, size_t body_size, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, const char* body_bytes,
+ size_t body_size, grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
static int httpcli_get_google_keys_for_email(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, good_google_email_keys());
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
@@ -341,22 +335,22 @@ static int httpcli_get_google_keys_for_email(
"/robot/v1/metadata/x509/"
"777-abaslkan11hlb6nmim3bpspl31ud@developer."
"gserviceaccount.com") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
-static void on_verification_success(grpc_exec_ctx* exec_ctx, void* user_data,
+static void on_verification_success(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_OK);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(user_data == (void*)expected_user_data);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), expected_audience) == 0);
- grpc_jwt_claims_destroy(exec_ctx, claims);
+ grpc_jwt_claims_destroy(claims);
}
static void test_jwt_verifier_google_email_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
@@ -369,28 +363,27 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_custom_keys_for_email(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "keys.bar.com") == 0);
GPR_ASSERT(strcmp(request->http.path, "/jwk/foo@bar.com") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_custom_email_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(&custom_mapping, 1);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_custom_email_issuer);
@@ -403,28 +396,26 @@ static void test_jwt_verifier_custom_email_issuer_success(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
-static int httpcli_get_jwk_set(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_jwk_set(const grpc_httpcli_request* request,
grpc_millis deadline, grpc_closure* on_done,
grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
GPR_ASSERT(strcmp(request->http.path, "/oauth2/v3/certs") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
-static int httpcli_get_openid_config(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_openid_config(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
@@ -434,12 +425,12 @@ static int httpcli_get_openid_config(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(strcmp(request->http.path, GRPC_OPENID_CONFIG_URL_SUFFIX) == 0);
grpc_httpcli_set_override(httpcli_get_jwk_set,
httpcli_post_should_not_be_called);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_url_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
@@ -452,16 +443,15 @@ static void test_jwt_verifier_url_issuer_success(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
-static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void on_verification_key_retrieval_error(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR);
@@ -469,18 +459,17 @@ static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(user_data == (void*)expected_user_data);
}
-static int httpcli_get_bad_json(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_bad_json(const grpc_httpcli_request* request,
grpc_millis deadline, grpc_closure* on_done,
grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}"));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_url_issuer_bad_config(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
@@ -493,17 +482,17 @@ static void test_jwt_verifier_url_issuer_bad_config(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_key_retrieval_error,
(void*)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
static void test_jwt_verifier_bad_json_key(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
@@ -516,11 +505,11 @@ static void test_jwt_verifier_bad_json_key(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_key_retrieval_error,
(void*)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
@@ -532,9 +521,8 @@ static void corrupt_jwt_sig(char* jwt) {
char* last_dot = strrchr(jwt, '.');
GPR_ASSERT(last_dot != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- sig = grpc_base64_decode(&exec_ctx, last_dot + 1, 1);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ sig = grpc_base64_decode(last_dot + 1, 1);
}
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
sig_bytes = GRPC_SLICE_START_PTR(sig);
@@ -546,8 +534,7 @@ static void corrupt_jwt_sig(char* jwt) {
grpc_slice_unref(sig);
}
-static void on_verification_bad_signature(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void on_verification_bad_signature(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_SIGNATURE);
@@ -556,7 +543,7 @@ static void on_verification_bad_signature(grpc_exec_ctx* exec_ctx,
}
static void test_jwt_verifier_bad_signature(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
@@ -570,17 +557,16 @@ static void test_jwt_verifier_bad_signature(void) {
grpc_auth_json_key_destruct(&key);
corrupt_jwt_sig(jwt);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_bad_signature,
(void*)expected_user_data);
gpr_free(jwt);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
grpc_httpcli_set_override(nullptr, nullptr);
}
-static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
@@ -588,7 +574,7 @@ static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
return 1;
}
-static void on_verification_bad_format(grpc_exec_ctx* exec_ctx, void* user_data,
+static void on_verification_bad_format(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_FORMAT);
@@ -597,15 +583,15 @@ static void on_verification_bad_format(grpc_exec_ctx* exec_ctx, void* user_data,
}
static void test_jwt_verifier_bad_format(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, "bad jwt",
- expected_audience, on_verification_bad_format,
+ grpc_jwt_verifier_verify(verifier, nullptr, "bad jwt", expected_audience,
+ on_verification_bad_format,
(void*)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
grpc_httpcli_set_override(nullptr, nullptr);
}
diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc
index 602041eecc..7551d7df85 100644
--- a/test/core/security/oauth2_utils.cc
+++ b/test/core/security/oauth2_utils.cc
@@ -39,8 +39,7 @@ typedef struct {
grpc_closure closure;
} oauth2_request;
-static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_oauth2_response(void* arg, grpc_error* error) {
oauth2_request* request = (oauth2_request*)arg;
char* token = nullptr;
grpc_slice token_slice;
@@ -54,25 +53,23 @@ static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_SLICE_LENGTH(token_slice));
token[GRPC_SLICE_LENGTH(token_slice)] = '\0';
}
- grpc_credentials_mdelem_array_destroy(exec_ctx, &request->md_array);
+ grpc_credentials_mdelem_array_destroy(&request->md_array);
gpr_mu_lock(request->mu);
request->is_done = true;
request->token = token;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&request->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&request->pops), nullptr));
gpr_mu_unlock(request->mu);
}
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* unused,
- grpc_error* error) {}
+static void do_nothing(void* unused, grpc_error* error) {}
char* grpc_test_fetch_oauth2_token_with_credentials(
grpc_call_credentials* creds) {
oauth2_request request;
memset(&request, 0, sizeof(request));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure do_nothing_closure;
grpc_auth_metadata_context null_ctx = {"", "", nullptr, nullptr};
@@ -88,31 +85,30 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
grpc_schedule_on_exec_ctx);
grpc_error* error = GRPC_ERROR_NONE;
- if (grpc_call_credentials_get_request_metadata(
- &exec_ctx, creds, &request.pops, null_ctx, &request.md_array,
- &request.closure, &error)) {
+ if (grpc_call_credentials_get_request_metadata(creds, &request.pops, null_ctx,
+ &request.md_array,
+ &request.closure, &error)) {
// Synchronous result; invoke callback directly.
- on_oauth2_response(&exec_ctx, &request, error);
+ on_oauth2_response(&request, error);
GRPC_ERROR_UNREF(error);
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(request.mu);
while (!request.is_done) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx,
- grpc_polling_entity_pollset(&request.pops),
+ grpc_pollset_work(grpc_polling_entity_pollset(&request.pops),
&worker, GRPC_MILLIS_INF_FUTURE))) {
request.is_done = true;
}
}
gpr_mu_unlock(request.mu);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&request.pops),
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&request.pops),
&do_nothing_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+
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 f4acf023bd..7089b9808a 100644
--- a/test/core/security/print_google_default_creds_token.cc
+++ b/test/core/security/print_google_default_creds_token.cc
@@ -41,8 +41,7 @@ typedef struct {
grpc_closure on_request_metadata;
} synchronizer;
-static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_metadata_response(void* arg, grpc_error* error) {
synchronizer* sync = static_cast<synchronizer*>(arg);
if (error != GRPC_ERROR_NONE) {
fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error));
@@ -57,14 +56,13 @@ static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg,
sync->is_done = true;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&sync->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&sync->pops), nullptr));
gpr_mu_unlock(sync->mu);
}
int main(int argc, char** argv) {
int result = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
synchronizer sync;
grpc_channel_credentials* creds = nullptr;
const char* service_url = "https://test.foo.google.com/Foo";
@@ -97,11 +95,10 @@ int main(int argc, char** argv) {
error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- &exec_ctx, ((grpc_composite_channel_credentials*)creds)->call_creds,
- &sync.pops, context, &sync.md_array, &sync.on_request_metadata,
- &error)) {
+ ((grpc_composite_channel_credentials*)creds)->call_creds, &sync.pops,
+ context, &sync.md_array, &sync.on_request_metadata, &error)) {
// Synchronous response. Invoke callback directly.
- on_metadata_response(&exec_ctx, &sync, error);
+ on_metadata_response(&sync, error);
GRPC_ERROR_UNREF(error);
}
@@ -110,18 +107,15 @@ int main(int argc, char** argv) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx,
- grpc_polling_entity_pollset(&sync.pops), &worker,
+ grpc_pollset_work(grpc_polling_entity_pollset(&sync.pops), &worker,
GRPC_MILLIS_INF_FUTURE)))
sync.is_done = true;
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(sync.mu);
}
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_finish(&exec_ctx);
-
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 a12af02479..14ca0a8927 100644
--- a/test/core/security/secure_endpoint_test.cc
+++ b/test/core/security/secure_endpoint_test.cc
@@ -38,7 +38,7 @@ static grpc_pollset* g_pollset;
static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
size_t slice_size, grpc_slice* leftover_slices, size_t leftover_nslices,
bool use_zero_copy_protector) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
tsi_frame_protector* fake_read_protector =
tsi_create_fake_frame_protector(nullptr);
tsi_frame_protector* fake_write_protector =
@@ -60,8 +60,8 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
tcp = grpc_iomgr_create_endpoint_pair("fixture", &args);
- grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, tcp.server, g_pollset);
+ grpc_endpoint_add_to_pollset(tcp.client, g_pollset);
+ grpc_endpoint_add_to_pollset(tcp.server, g_pollset);
if (leftover_nslices == 0) {
f.client_ep = grpc_secure_endpoint_create(fake_read_protector,
@@ -117,7 +117,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, nullptr, 0);
- grpc_exec_ctx_finish(&exec_ctx);
+
return f;
}
@@ -165,52 +165,46 @@ static grpc_endpoint_test_config configs[] = {
clean_up},
};
-static void inc_call_ctr(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- ++*(int*)arg;
-}
+static void inc_call_ctr(void* arg, grpc_error* error) { ++*(int*)arg; }
static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
grpc_endpoint_test_fixture f = config.create_fixture(slice_size);
grpc_slice_buffer incoming;
grpc_slice s =
grpc_slice_from_copied_string("hello world 12345678900987654321");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
int n = 0;
grpc_closure done_closure;
gpr_log(GPR_INFO, "Start test left over");
grpc_slice_buffer_init(&incoming);
GRPC_CLOSURE_INIT(&done_closure, inc_call_ctr, &n, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &incoming, &done_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_read(f.client_ep, &incoming, &done_closure);
+
GPR_ASSERT(n == 1);
GPR_ASSERT(incoming.count == 1);
GPR_ASSERT(grpc_slice_eq(s, incoming.slices[0]));
grpc_endpoint_shutdown(
- &exec_ctx, f.client_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
+ f.client_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
grpc_endpoint_shutdown(
- &exec_ctx, f.server_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
- grpc_endpoint_destroy(&exec_ctx, f.client_ep);
- grpc_endpoint_destroy(&exec_ctx, f.server_ep);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_slice_unref_internal(&exec_ctx, s);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &incoming);
+ 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_slice_unref_internal(s);
+ grpc_slice_buffer_destroy_internal(&incoming);
clean_up();
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
@@ -222,8 +216,8 @@ int main(int argc, char** argv) {
test_leftover(configs[3], 1);
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
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 bbb2f6013e..df62dc17b8 100644
--- a/test/core/security/ssl_server_fuzzer.cc
+++ b/test/core/security/ssl_server_fuzzer.cc
@@ -40,8 +40,7 @@ struct handshake_state {
bool done_callback_called;
};
-static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_handshake_done(void* arg, grpc_error* error) {
grpc_handshaker_args* args = static_cast<grpc_handshaker_args*>(arg);
struct handshake_state* state =
static_cast<struct handshake_state*>(args->user_data);
@@ -56,17 +55,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
if (leak_check) grpc_memory_counters_init();
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("ssl_server_fuzzer");
grpc_endpoint* mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char*)data, size));
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
// Load key pair and establish server SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
@@ -83,38 +81,37 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Create security connector
grpc_server_security_connector* sc = nullptr;
grpc_security_status status =
- grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
+ 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(&exec_ctx);
+ grpc_millis deadline = GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now();
struct handshake_state state;
state.done_callback_called = false;
grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create();
- grpc_server_security_connector_add_handshakers(&exec_ctx, sc, handshake_mgr);
+ grpc_server_security_connector_add_handshakers(sc, handshake_mgr);
grpc_handshake_manager_do_handshake(
- &exec_ctx, handshake_mgr, mock_endpoint, nullptr /* channel_args */,
- deadline, nullptr /* acceptor */, on_handshake_done, &state);
- grpc_exec_ctx_flush(&exec_ctx);
+ handshake_mgr, mock_endpoint, nullptr /* channel_args */, deadline,
+ nullptr /* acceptor */, on_handshake_done, &state);
+ grpc_core::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
// the endpoint.
if (!state.done_callback_called) {
grpc_endpoint_shutdown(
- &exec_ctx, mock_endpoint,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Explicit close"));
- grpc_exec_ctx_flush(&exec_ctx);
+ mock_endpoint, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Explicit close"));
+ grpc_core::ExecCtx::Get()->Flush();
}
GPR_ASSERT(state.done_callback_called);
- grpc_handshake_manager_destroy(&exec_ctx, handshake_mgr);
- GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "test");
+ grpc_handshake_manager_destroy(handshake_mgr);
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "test");
grpc_server_credentials_release(creds);
grpc_slice_unref(cert_slice);
grpc_slice_unref(key_slice);
grpc_slice_unref(ca_slice);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::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 787d58bc37..1bd92bbc97 100644
--- a/test/core/security/verify_jwt.cc
+++ b/test/core/security/verify_jwt.cc
@@ -44,7 +44,7 @@ static void print_usage_and_exit(gpr_cmdline* cl, const char* argv0) {
exit(1);
}
-static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
+static void on_jwt_verification_done(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
synchronizer* sync = static_cast<synchronizer*>(user_data);
@@ -57,7 +57,7 @@ static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_json_dump_to_string((grpc_json*)grpc_jwt_claims_json(claims), 2);
printf("Claims: \n\n%s\n", claims_str);
gpr_free(claims_str);
- grpc_jwt_claims_destroy(exec_ctx, claims);
+ grpc_jwt_claims_destroy(claims);
} else {
GPR_ASSERT(claims == nullptr);
fprintf(stderr, "Verification failed with error %s\n",
@@ -66,8 +66,7 @@ static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
gpr_mu_lock(sync->mu);
sync->is_done = 1;
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, sync->pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(sync->pollset, nullptr));
gpr_mu_unlock(sync->mu);
}
@@ -77,7 +76,7 @@ int main(int argc, char** argv) {
gpr_cmdline* cl;
const char* jwt = nullptr;
const char* aud = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_init();
cl = gpr_cmdline_create("JWT verifier tool");
@@ -96,26 +95,26 @@ int main(int argc, char** argv) {
grpc_pollset_init(sync.pollset, &sync.mu);
sync.is_done = 0;
- grpc_jwt_verifier_verify(&exec_ctx, verifier, sync.pollset, jwt, aud,
+ grpc_jwt_verifier_verify(verifier, sync.pollset, jwt, aud,
on_jwt_verification_done, &sync);
gpr_mu_lock(sync.mu);
while (!sync.is_done) {
grpc_pollset_worker* worker = nullptr;
- if (!GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, sync.pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)))
+ if (!GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(sync.pollset, &worker, GRPC_MILLIS_INF_FUTURE)))
sync.is_done = true;
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(sync.mu);
}
gpr_mu_unlock(sync.mu);
gpr_free(sync.pollset);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
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 479198f9f9..08a5770b2a 100644
--- a/test/core/slice/b64_test.cc
+++ b/test/core/slice/b64_test.cc
@@ -44,14 +44,14 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) {
const char* hello = "hello";
char* hello_b64 =
grpc_base64_encode(hello, strlen(hello), url_safe, multiline);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice hello_slice = grpc_base64_decode(&exec_ctx, hello_b64, url_safe);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello));
GPR_ASSERT(strncmp((const char*)GRPC_SLICE_START_PTR(hello_slice), hello,
GRPC_SLICE_LENGTH(hello_slice)) == 0);
- grpc_slice_unref_internal(&exec_ctx, hello_slice);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(hello_slice);
+
gpr_free(hello_b64);
}
@@ -64,15 +64,14 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
/* Try all the different paddings. */
for (i = 0; i < 3; i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
+ orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i));
GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded),
sizeof(orig) - i));
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_slice_unref_internal(orig_decoded);
gpr_free(b64);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -116,19 +115,18 @@ static void test_url_safe_unsafe_mismatch_failure(void) {
int url_safe = 1;
for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, !url_safe);
+ orig_decoded = grpc_base64_decode(b64, !url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_slice_unref_internal(orig_decoded);
b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
+ orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(orig_decoded);
}
static void test_rfc4648_test_vectors(void) {
@@ -166,40 +164,39 @@ static void test_rfc4648_test_vectors(void) {
static void test_unpadded_decode(void) {
grpc_slice decoded;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmFy", 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ decoded = grpc_base64_decode("Zm9vYmFy", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmE", 0);
+ decoded = grpc_base64_decode("Zm9vYmE", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYg", 0);
+ decoded = grpc_base64_decode("Zm9vYg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9v", 0);
+ decoded = grpc_base64_decode("Zm9v", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm8", 0);
+ decoded = grpc_base64_decode("Zm8", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zg", 0);
+ decoded = grpc_base64_decode("Zg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "", 0);
+ decoded = grpc_base64_decode("", 0);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded));
- grpc_exec_ctx_finish(&exec_ctx);
}
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 0ee4e8617d..26c2938782 100644
--- a/test/core/slice/slice_hash_table_test.cc
+++ b/test/core/slice/slice_hash_table_test.cc
@@ -59,9 +59,7 @@ static void check_non_existent_value(const char* key_string,
grpc_slice_unref(key);
}
-static void destroy_string(grpc_exec_ctx* exec_ctx, void* value) {
- gpr_free(value);
-}
+static void destroy_string(void* value) { gpr_free(value); }
static grpc_slice_hash_table* create_table_from_entries(
const test_entry* test_entries, size_t num_test_entries,
@@ -121,9 +119,8 @@ static void test_slice_hash_table() {
check_values(test_entries, num_entries, table);
check_non_existent_value("XX", table);
// Clean up.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_hash_table_unref(table);
}
static int value_cmp_fn(void* a, void* b) {
@@ -149,10 +146,9 @@ static void test_slice_hash_table_eq() {
create_table_from_entries(test_entries_b, num_entries_b, value_cmp_fn);
GPR_ASSERT(grpc_slice_hash_table_cmp(table_a, table_b) == 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table_a);
- grpc_slice_hash_table_unref(&exec_ctx, table_b);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_hash_table_unref(table_a);
+ grpc_slice_hash_table_unref(table_b);
}
static void test_slice_hash_table_not_eq() {
@@ -221,17 +217,16 @@ static void test_slice_hash_table_not_eq() {
create_table_from_entries(test_entries_h, num_entries_h, pointer_cmp_fn);
GPR_ASSERT(grpc_slice_hash_table_cmp(table_g, table_h) != 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table_a);
- grpc_slice_hash_table_unref(&exec_ctx, table_b_larger);
- grpc_slice_hash_table_unref(&exec_ctx, table_b_smaller);
- grpc_slice_hash_table_unref(&exec_ctx, table_c);
- grpc_slice_hash_table_unref(&exec_ctx, table_d);
- grpc_slice_hash_table_unref(&exec_ctx, table_e);
- grpc_slice_hash_table_unref(&exec_ctx, table_f);
- grpc_slice_hash_table_unref(&exec_ctx, table_g);
- grpc_slice_hash_table_unref(&exec_ctx, table_h);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_hash_table_unref(table_a);
+ grpc_slice_hash_table_unref(table_b_larger);
+ grpc_slice_hash_table_unref(table_b_smaller);
+ grpc_slice_hash_table_unref(table_c);
+ grpc_slice_hash_table_unref(table_d);
+ grpc_slice_hash_table_unref(table_e);
+ grpc_slice_hash_table_unref(table_f);
+ grpc_slice_hash_table_unref(table_g);
+ grpc_slice_hash_table_unref(table_h);
}
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 e5d2d7c78d..f9ce98da21 100644
--- a/test/core/surface/byte_buffer_reader_test.cc
+++ b/test/core/surface/byte_buffer_reader_test.cc
@@ -132,10 +132,8 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
memset(GRPC_SLICE_START_PTR(input_slice), 'a', input_size);
grpc_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(
- grpc_msg_compress(&exec_ctx, algorithm, &sliceb_in, &sliceb_out));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out));
}
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 f358b0fc8d..65fac9daa3 100644
--- a/test/core/surface/channel_create_test.cc
+++ b/test/core/surface/channel_create_test.cc
@@ -35,11 +35,10 @@ void test_unknown_scheme_target(void) {
chan = grpc_insecure_channel_create("blah://blah", nullptr, nullptr);
GPR_ASSERT(chan != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
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(&exec_ctx);
grpc_channel_destroy(chan);
}
diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc
index c6e13d2386..3452f78a3b 100644
--- a/test/core/surface/completion_queue_test.cc
+++ b/test/core/surface/completion_queue_test.cc
@@ -121,8 +121,7 @@ static void test_wait_empty(void) {
}
}
-static void do_nothing_end_completion(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_cq_completion* c) {}
+static void do_nothing_end_completion(void* arg, grpc_cq_completion* c) {}
static void test_cq_end_op(void) {
grpc_event ev;
@@ -131,8 +130,6 @@ static void test_cq_end_op(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
void* tag = create_test_tag();
LOG_TEST("test_cq_end_op");
@@ -140,14 +137,14 @@ static void test_cq_end_op(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_NEXT;
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
- exec_ctx = init_exec_ctx; // Reset exec_ctx
+ grpc_core::ExecCtx _local_exec_ctx;
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
GPR_ASSERT(grpc_cq_begin_op(cc, tag));
- grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE,
- do_nothing_end_completion, nullptr, &completion);
+ grpc_cq_end_op(cc, tag, GRPC_ERROR_NONE, do_nothing_end_completion, nullptr,
+ &completion);
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
@@ -156,7 +153,6 @@ static void test_cq_end_op(void) {
GPR_ASSERT(ev.success);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -167,8 +163,6 @@ static void test_cq_tls_cache_full(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
void* tag = create_test_tag();
void* res_tag;
int ok;
@@ -178,15 +172,15 @@ static void test_cq_tls_cache_full(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_NEXT;
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
- exec_ctx = init_exec_ctx; // Reset exec_ctx
+ grpc_core::ExecCtx _local_exec_ctx; // Reset exec_ctx
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue_thread_local_cache_init(cc);
GPR_ASSERT(grpc_cq_begin_op(cc, tag));
- grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE,
- do_nothing_end_completion, nullptr, &completion);
+ grpc_cq_end_op(cc, tag, GRPC_ERROR_NONE, do_nothing_end_completion, nullptr,
+ &completion);
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
@@ -202,7 +196,6 @@ static void test_cq_tls_cache_full(void) {
GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -211,8 +204,6 @@ static void test_cq_tls_cache_empty(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
void* res_tag;
int ok;
@@ -221,7 +212,7 @@ static void test_cq_tls_cache_empty(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_NEXT;
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
- exec_ctx = init_exec_ctx; // Reset exec_ctx
+ grpc_core::ExecCtx _local_exec_ctx; // Reset exec_ctx
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
@@ -232,7 +223,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(&exec_ctx);
}
}
@@ -289,8 +279,6 @@ static void test_pluck(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
unsigned i, j;
LOG_TEST("test_pluck");
@@ -305,15 +293,15 @@ static void test_pluck(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_PLUCK;
for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) {
- exec_ctx = init_exec_ctx; // reset exec_ctx
+ grpc_core::ExecCtx _local_exec_ctx; // reset exec_ctx
attr.cq_polling_type = polling_types[pidx];
cc = grpc_completion_queue_create(
grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
- grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, nullptr, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -324,8 +312,8 @@ static void test_pluck(void) {
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
- grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, nullptr, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -336,7 +324,6 @@ static void test_pluck(void) {
}
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc
index af54e00c4a..d923387e23 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -59,8 +59,7 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) {
grpc_completion_queue_destroy(cc);
}
-static void do_nothing_end_completion(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_cq_completion* c) {}
+static void do_nothing_end_completion(void* arg, grpc_cq_completion* c) {}
struct thread_state {
grpc_completion_queue* cc;
@@ -81,7 +80,7 @@ static void test_too_many_plucks(void) {
gpr_thd_id thread_ids[GPR_ARRAY_SIZE(tags)];
struct thread_state thread_states[GPR_ARRAY_SIZE(tags)];
gpr_thd_options thread_options = gpr_thd_options_default();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
unsigned i, j;
LOG_TEST("test_too_many_plucks");
@@ -108,8 +107,8 @@ static void test_too_many_plucks(void) {
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
- grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, nullptr, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -117,7 +116,6 @@ static void test_too_many_plucks(void) {
}
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
#define TEST_THREAD_EVENTS 10000
@@ -137,15 +135,14 @@ gpr_timespec ten_seconds_time(void) {
return grpc_timeout_seconds_to_deadline(10);
}
-static void free_completion(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_cq_completion* completion) {
+static void free_completion(void* arg, grpc_cq_completion* completion) {
gpr_free(completion);
}
static void producer_thread(void* arg) {
test_thread_options* opt = static_cast<test_thread_options*>(arg);
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "producer %d started", opt->id);
gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
@@ -162,17 +159,15 @@ static void producer_thread(void* arg) {
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- grpc_cq_end_op(&exec_ctx, opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE,
+ grpc_cq_end_op(opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE,
free_completion, nullptr,
static_cast<grpc_cq_completion*>(
gpr_malloc(sizeof(grpc_cq_completion))));
opt->events_triggered++;
- grpc_exec_ctx_finish(&exec_ctx);
}
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(&exec_ctx);
}
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 8fa15ab331..5771e2f240 100644
--- a/test/core/surface/concurrent_connectivity_test.cc
+++ b/test/core/surface/concurrent_connectivity_test.cc
@@ -101,29 +101,28 @@ void server_thread(void* vargs) {
GPR_ASSERT(detag(ev.tag) == 0xd1e);
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* vargs, grpc_endpoint* tcp,
+static void on_connect(void* vargs, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
struct server_thread_args* args = (struct server_thread_args*)vargs;
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
void bad_server_thread(void* vargs) {
struct server_thread_args* args = (struct server_thread_args*)vargs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
int port;
grpc_tcp_server* s;
- grpc_error* error = grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s);
+ grpc_error* error = grpc_tcp_server_create(nullptr, nullptr, &s);
GPR_ASSERT(error == GRPC_ERROR_NONE);
memset(&resolved_addr, 0, sizeof(resolved_addr));
addr->ss_family = AF_INET;
@@ -132,35 +131,32 @@ void bad_server_thread(void* vargs) {
GPR_ASSERT(port > 0);
gpr_asprintf(&args->addr, "localhost:%d", port);
- grpc_tcp_server_start(&exec_ctx, s, &args->pollset, 1, on_connect, args);
+ grpc_tcp_server_start(s, &args->pollset, 1, on_connect, args);
gpr_event_set(&args->ready, (void*)1);
gpr_mu_lock(args->mu);
while (gpr_atm_acq_load(&args->stop) == 0) {
- grpc_millis deadline = grpc_exec_ctx_now(&exec_ctx) + 100;
+ grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 100;
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker, deadline))) {
+ grpc_pollset_work(args->pollset, &worker, deadline))) {
gpr_atm_rel_store(&args->stop, 1);
}
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(args->mu);
}
gpr_mu_unlock(args->mu);
- grpc_tcp_server_unref(&exec_ctx, s);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
gpr_free(args->addr);
}
-static void done_pollset_shutdown(grpc_exec_ctx* exec_ctx, void* pollset,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(pollset));
+static void done_pollset_shutdown(void* pollset, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(pollset));
gpr_free(pollset);
}
@@ -228,11 +224,10 @@ int run_concurrent_connectivity_test() {
gpr_atm_rel_store(&args.stop, 1);
gpr_thd_join(server);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_shutdown(&exec_ctx, args.pollset,
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_pollset_shutdown(args.pollset,
GRPC_CLOSURE_CREATE(done_pollset_shutdown, args.pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
diff --git a/test/core/surface/lame_client_test.cc b/test/core/surface/lame_client_test.cc
index f3df7f35a7..258ee6a831 100644
--- a/test/core/surface/lame_client_test.cc
+++ b/test/core/surface/lame_client_test.cc
@@ -32,20 +32,19 @@ grpc_closure transport_op_cb;
static void* tag(intptr_t x) { return (void*)x; }
-void verify_connectivity(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+void verify_connectivity(void* arg, grpc_error* error) {
grpc_connectivity_state* state = static_cast<grpc_connectivity_state*>(arg);
GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == *state);
GPR_ASSERT(error == GRPC_ERROR_NONE);
}
-void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+void do_nothing(void* arg, grpc_error* error) {}
void test_transport_op(grpc_channel* channel) {
grpc_transport_op* op;
grpc_channel_element* elem;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_CLOSURE_INIT(&transport_op_cb, verify_connectivity, &state,
grpc_schedule_on_exec_ctx);
@@ -54,14 +53,12 @@ void test_transport_op(grpc_channel* channel) {
op->on_connectivity_state_change = &transport_op_cb;
op->connectivity_state = &state;
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
- elem->filter->start_transport_op(&exec_ctx, elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ elem->filter->start_transport_op(elem, op);
GRPC_CLOSURE_INIT(&transport_op_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
op = grpc_make_transport_op(&transport_op_cb);
- elem->filter->start_transport_op(&exec_ctx, elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ elem->filter->start_transport_op(elem, op);
}
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 f78d333673..4052f19f51 100644
--- a/test/core/surface/num_external_connectivity_watchers_test.cc
+++ b/test/core/surface/num_external_connectivity_watchers_test.cc
@@ -178,9 +178,8 @@ static grpc_channel* secure_test_create_channel(const char* addr) {
grpc_channel* channel =
grpc_secure_channel_create(ssl_creds, addr, new_client_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
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 c31c61430c..62c2d92885 100644
--- a/test/core/surface/secure_channel_create_test.cc
+++ b/test/core/surface/secure_channel_create_test.cc
@@ -37,10 +37,9 @@ 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 exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_channel_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
+ grpc_channel_credentials_unref(creds);
}
void test_security_connector_already_in_arg(void) {
@@ -56,9 +55,8 @@ void test_security_connector_already_in_arg(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 exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
}
void test_null_creds(void) {
@@ -67,9 +65,8 @@ void test_null_creds(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 exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
}
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 015db92cb0..e7ae97908c 100644
--- a/test/core/surface/sequential_connectivity_test.cc
+++ b/test/core/surface/sequential_connectivity_test.cc
@@ -156,9 +156,8 @@ static grpc_channel* secure_test_create_channel(const char* addr) {
grpc_channel* channel =
grpc_secure_channel_create(ssl_creds, addr, new_client_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
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 2a6fa95162..168807adde 100644
--- a/test/core/transport/bdp_estimator_test.cc
+++ b/test/core/transport/bdp_estimator_test.cc
@@ -58,7 +58,7 @@ namespace {
void AddSamples(BdpEstimator* estimator, int64_t* samples, size_t n) {
estimator->AddIncomingBytes(1234567);
inc_time();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
estimator->SchedulePing();
estimator->StartPing();
for (size_t i = 0; i < n; i++) {
@@ -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(&exec_ctx);
- estimator->CompletePing(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ estimator->CompletePing();
}
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 0e34fd7651..593c2ae141 100644
--- a/test/core/transport/byte_stream_test.cc
+++ b/test/core/transport/byte_stream_test.cc
@@ -30,14 +30,13 @@
// grpc_slice_buffer_stream tests
//
-static void not_called_closure(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void not_called_closure(void* arg, grpc_error* error) {
GPR_ASSERT(false);
}
static void test_slice_buffer_stream_basic(void) {
gpr_log(GPR_DEBUG, "test_slice_buffer_stream_basic");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -57,23 +56,21 @@ static void test_slice_buffer_stream_basic(void) {
grpc_schedule_on_exec_ctx);
// Read each slice. Note that next() always returns synchronously.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_slice_buffer_stream_shutdown(void) {
gpr_log(GPR_DEBUG, "test_slice_buffer_stream_shutdown");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -92,29 +89,25 @@ static void test_slice_buffer_stream_shutdown(void) {
GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read the first slice.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Now shutdown.
grpc_error* shutdown_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("shutdown error");
- grpc_byte_stream_shutdown(&exec_ctx, &stream.base,
- GRPC_ERROR_REF(shutdown_error));
+ grpc_byte_stream_shutdown(&stream.base, GRPC_ERROR_REF(shutdown_error));
// After shutdown, the next pull() should return the error.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == shutdown_error);
GRPC_ERROR_UNREF(error);
GRPC_ERROR_UNREF(shutdown_error);
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
//
@@ -123,7 +116,7 @@ static void test_slice_buffer_stream_shutdown(void) {
static void test_caching_byte_stream_basic(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_basic");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -147,24 +140,22 @@ static void test_caching_byte_stream_basic(void) {
// Read each slice. Note that next() always returns synchronously,
// because the underlying byte stream always does.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_caching_byte_stream_reset(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_reset");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -186,34 +177,31 @@ static void test_caching_byte_stream_reset(void) {
GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read one slice.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Reset the caching stream. The reads should start over from the
// first slice.
grpc_caching_byte_stream_reset(&stream);
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_caching_byte_stream_shared_cache(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_shared_cache");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -237,35 +225,31 @@ static void test_caching_byte_stream_shared_cache(void) {
GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read one slice from stream1.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream1.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream1.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream1.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream1.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Read all slices from stream2.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream2.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream2.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream2.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream2.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Now read the second slice from stream1.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream1.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream1.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream1.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream1.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[1], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream1.base);
- grpc_byte_stream_destroy(&exec_ctx, &stream2.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream1.base);
+ grpc_byte_stream_destroy(&stream2.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
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 a29ec8a13f..897d3008b9 100644
--- a/test/core/transport/chttp2/bin_decoder_test.cc
+++ b/test/core/transport/chttp2/bin_decoder_test.cc
@@ -29,8 +29,8 @@
static int all_ok = 1;
-static void expect_slice_eq(grpc_exec_ctx* exec_ctx, grpc_slice expected,
- grpc_slice slice, const char* debug, int line) {
+static void expect_slice_eq(grpc_slice expected, grpc_slice slice,
+ const char* debug, int line) {
if (!grpc_slice_eq(slice, expected)) {
char* hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -40,104 +40,94 @@ static void expect_slice_eq(grpc_exec_ctx* exec_ctx, grpc_slice expected,
gpr_free(he);
all_ok = 0;
}
- grpc_slice_unref_internal(exec_ctx, expected);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(expected);
+ grpc_slice_unref_internal(slice);
}
-static grpc_slice base64_encode(grpc_exec_ctx* exec_ctx, const char* s) {
+static grpc_slice base64_encode(const char* s) {
grpc_slice ss = grpc_slice_from_copied_string(s);
grpc_slice out = grpc_chttp2_base64_encode(ss);
- grpc_slice_unref_internal(exec_ctx, ss);
+ grpc_slice_unref_internal(ss);
return out;
}
-static grpc_slice base64_decode(grpc_exec_ctx* exec_ctx, const char* s) {
+static grpc_slice base64_decode(const char* s) {
grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out = grpc_chttp2_base64_decode(exec_ctx, ss);
- grpc_slice_unref_internal(exec_ctx, ss);
+ grpc_slice out = grpc_chttp2_base64_decode(ss);
+ grpc_slice_unref_internal(ss);
return out;
}
-static grpc_slice base64_decode_with_length(grpc_exec_ctx* exec_ctx,
- const char* s,
+static grpc_slice base64_decode_with_length(const char* s,
size_t output_length) {
grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out =
- grpc_chttp2_base64_decode_with_length(exec_ctx, ss, output_length);
- grpc_slice_unref_internal(exec_ctx, ss);
+ grpc_slice out = grpc_chttp2_base64_decode_with_length(ss, output_length);
+ grpc_slice_unref_internal(ss);
return out;
}
-#define EXPECT_SLICE_EQ(exec_ctx, expected, slice) \
- expect_slice_eq( \
- exec_ctx, grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), \
- slice, #slice, __LINE__);
+#define EXPECT_SLICE_EQ(expected, slice) \
+ expect_slice_eq( \
+ grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \
+ #slice, __LINE__);
-#define ENCODE_AND_DECODE(exec_ctx, s) \
- EXPECT_SLICE_EQ(exec_ctx, s, \
- grpc_chttp2_base64_decode_with_length( \
- exec_ctx, base64_encode(exec_ctx, s), strlen(s)));
+#define ENCODE_AND_DECODE(s) \
+ EXPECT_SLICE_EQ( \
+ s, grpc_chttp2_base64_decode_with_length(base64_encode(s), strlen(s)));
int main(int argc, char** argv) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* ENCODE_AND_DECODE tests grpc_chttp2_base64_decode_with_length(), which
takes encoded base64 strings without pad chars, but output length is
required. */
/* Base64 test vectors from RFC 4648 */
- ENCODE_AND_DECODE(&exec_ctx, "");
- ENCODE_AND_DECODE(&exec_ctx, "f");
- ENCODE_AND_DECODE(&exec_ctx, "foo");
- ENCODE_AND_DECODE(&exec_ctx, "fo");
- ENCODE_AND_DECODE(&exec_ctx, "foob");
- ENCODE_AND_DECODE(&exec_ctx, "fooba");
- ENCODE_AND_DECODE(&exec_ctx, "foobar");
+ ENCODE_AND_DECODE("");
+ ENCODE_AND_DECODE("f");
+ ENCODE_AND_DECODE("foo");
+ ENCODE_AND_DECODE("fo");
+ ENCODE_AND_DECODE("foob");
+ ENCODE_AND_DECODE("fooba");
+ ENCODE_AND_DECODE("foobar");
- ENCODE_AND_DECODE(&exec_ctx, "\xc0\xc1\xc2\xc3\xc4\xc5");
+ ENCODE_AND_DECODE("\xc0\xc1\xc2\xc3\xc4\xc5");
/* Base64 test vectors from RFC 4648, with pad chars */
/* BASE64("") = "" */
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, ""));
+ EXPECT_SLICE_EQ("", base64_decode(""));
/* BASE64("f") = "Zg==" */
- EXPECT_SLICE_EQ(&exec_ctx, "f", base64_decode(&exec_ctx, "Zg=="));
+ EXPECT_SLICE_EQ("f", base64_decode("Zg=="));
/* BASE64("fo") = "Zm8=" */
- EXPECT_SLICE_EQ(&exec_ctx, "fo", base64_decode(&exec_ctx, "Zm8="));
+ EXPECT_SLICE_EQ("fo", base64_decode("Zm8="));
/* BASE64("foo") = "Zm9v" */
- EXPECT_SLICE_EQ(&exec_ctx, "foo", base64_decode(&exec_ctx, "Zm9v"));
+ EXPECT_SLICE_EQ("foo", base64_decode("Zm9v"));
/* BASE64("foob") = "Zm9vYg==" */
- EXPECT_SLICE_EQ(&exec_ctx, "foob", base64_decode(&exec_ctx, "Zm9vYg=="));
+ EXPECT_SLICE_EQ("foob", base64_decode("Zm9vYg=="));
/* BASE64("fooba") = "Zm9vYmE=" */
- EXPECT_SLICE_EQ(&exec_ctx, "fooba", base64_decode(&exec_ctx, "Zm9vYmE="));
+ EXPECT_SLICE_EQ("fooba", base64_decode("Zm9vYmE="));
/* BASE64("foobar") = "Zm9vYmFy" */
- EXPECT_SLICE_EQ(&exec_ctx, "foobar", base64_decode(&exec_ctx, "Zm9vYmFy"));
+ EXPECT_SLICE_EQ("foobar", base64_decode("Zm9vYmFy"));
- EXPECT_SLICE_EQ(&exec_ctx, "\xc0\xc1\xc2\xc3\xc4\xc5",
- base64_decode(&exec_ctx, "wMHCw8TF"));
+ EXPECT_SLICE_EQ("\xc0\xc1\xc2\xc3\xc4\xc5", base64_decode("wMHCw8TF"));
// Test illegal input length in grpc_chttp2_base64_decode
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "a"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "ab"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "abc"));
+ EXPECT_SLICE_EQ("", base64_decode("a"));
+ EXPECT_SLICE_EQ("", base64_decode("ab"));
+ EXPECT_SLICE_EQ("", base64_decode("abc"));
// Test illegal charactors in grpc_chttp2_base64_decode
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "Zm:v"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "Zm=v"));
+ EXPECT_SLICE_EQ("", base64_decode("Zm:v"));
+ EXPECT_SLICE_EQ("", base64_decode("Zm=v"));
// Test output_length longer than max possible output length in
// grpc_chttp2_base64_decode_with_length
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode_with_length(&exec_ctx, "Zg", 2));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm8", 3));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm9v", 4));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zg", 2));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm8", 3));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm9v", 4));
// Test illegal charactors in grpc_chttp2_base64_decode_with_length
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm:v", 3));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm=v", 3));
-
- grpc_exec_ctx_finish(&exec_ctx);
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm:v", 3));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm=v", 3));
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 2d18b72504..2772aef3c4 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.cc
+++ b/test/core/transport/chttp2/hpack_encoder_test.cc
@@ -51,8 +51,8 @@ typedef struct {
/* verify that the output generated by encoding the stream matches the
hexstring passed in */
-static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
- const char* expected, size_t nheaders, ...) {
+static void verify(const verify_params params, const char* expected,
+ size_t nheaders, ...) {
grpc_slice_buffer output;
grpc_slice merged;
grpc_slice expect = parse_hexstring(expected);
@@ -77,8 +77,7 @@ static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
value_slice = grpc_slice_intern(value_slice);
}
e[i].md = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
- value_slice);
+ grpc_slice_intern(grpc_slice_from_static_string(key)), value_slice);
}
e[0].prev = nullptr;
e[nheaders - 1].next = nullptr;
@@ -106,11 +105,10 @@ static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
16384, /* max_frame_size */
&stats /* stats */
};
- grpc_chttp2_encode_header(exec_ctx, &g_compressor, nullptr, 0, &b, &hopt,
- &output);
+ grpc_chttp2_encode_header(&g_compressor, nullptr, 0, &b, &hopt, &output);
merged = grpc_slice_merge(output.slices, output.count);
- grpc_slice_buffer_destroy_internal(exec_ctx, &output);
- grpc_metadata_batch_destroy(exec_ctx, &b);
+ grpc_slice_buffer_destroy_internal(&output);
+ grpc_metadata_batch_destroy(&b);
if (!grpc_slice_eq(merged, expect)) {
char* expect_str = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -123,11 +121,11 @@ static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
g_failure = 1;
}
- grpc_slice_unref_internal(exec_ctx, merged);
- grpc_slice_unref_internal(exec_ctx, expect);
+ grpc_slice_unref_internal(merged);
+ grpc_slice_unref_internal(expect);
}
-static void test_basic_headers(grpc_exec_ctx* exec_ctx) {
+static void test_basic_headers() {
int i;
verify_params params = {
@@ -135,24 +133,22 @@ static void test_basic_headers(grpc_exec_ctx* exec_ctx) {
false,
false,
};
- verify(exec_ctx, params, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a");
- verify(exec_ctx, params, "000001 0104 deadbeef be", 1, "a", "a");
- verify(exec_ctx, params, "000001 0104 deadbeef be", 1, "a", "a");
- verify(exec_ctx, params, "000006 0104 deadbeef be 40 0162 0163", 2, "a", "a",
- "b", "c");
- verify(exec_ctx, params, "000002 0104 deadbeef bf be", 2, "a", "a", "b", "c");
- verify(exec_ctx, params, "000004 0104 deadbeef 7f 00 0164", 1, "a", "d");
+ verify(params, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a");
+ verify(params, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(params, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(params, "000006 0104 deadbeef be 40 0162 0163", 2, "a", "a", "b", "c");
+ verify(params, "000002 0104 deadbeef bf be", 2, "a", "a", "b", "c");
+ verify(params, "000004 0104 deadbeef 7f 00 0164", 1, "a", "d");
/* flush out what's there to make a few values look very popular */
for (i = 0; i < 350; i++) {
- verify(exec_ctx, params, "000003 0104 deadbeef c0 bf be", 3, "a", "a", "b",
- "c", "a", "d");
+ verify(params, "000003 0104 deadbeef c0 bf be", 3, "a", "a", "b", "c", "a",
+ "d");
}
- verify(exec_ctx, params, "000006 0104 deadbeef c0 00 016b 0176", 2, "a", "a",
- "k", "v");
+ verify(params, "000006 0104 deadbeef c0 00 016b 0176", 2, "a", "a", "k", "v");
/* this could be 000004 0104 deadbeef 0f 30 0176 also */
- verify(exec_ctx, params, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v");
+ verify(params, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v");
}
static void encode_int_to_str(int i, char* p) {
@@ -163,7 +159,7 @@ static void encode_int_to_str(int i, char* p) {
p[2] = 0;
}
-static void test_decode_table_overflow(grpc_exec_ctx* exec_ctx) {
+static void test_decode_table_overflow() {
int i;
char key[3], value[3];
char* expect;
@@ -192,26 +188,24 @@ static void test_decode_table_overflow(grpc_exec_ctx* exec_ctx) {
}
if (i > 0) {
- verify(exec_ctx, params, expect, 2, "aa", "ba", key, value);
+ verify(params, expect, 2, "aa", "ba", key, value);
} else {
- verify(exec_ctx, params, expect, 1, key, value);
+ verify(params, expect, 1, key, value);
}
gpr_free(expect);
}
/* if the above passes, then we must have just knocked this pair out of the
decoder stack, and so we'll be forced to re-encode it */
- verify(exec_ctx, params, "000007 0104 deadbeef 40 026161 026261", 1, "aa",
- "ba");
+ verify(params, "000007 0104 deadbeef 40 026161 026261", 1, "aa", "ba");
}
-static void verify_table_size_change_match_elem_size(grpc_exec_ctx* exec_ctx,
- const char* key,
+static void verify_table_size_change_match_elem_size(const char* key,
const char* value,
bool use_true_binary) {
grpc_slice_buffer output;
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
+ grpc_slice_intern(grpc_slice_from_static_string(key)),
grpc_slice_intern(grpc_slice_from_static_string(value)));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, use_true_binary);
size_t initial_table_size = g_compressor.table_size;
@@ -235,41 +229,38 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx* exec_ctx,
use_true_binary, /* use_true_binary_metadata */
16384, /* max_frame_size */
&stats /* stats */};
- grpc_chttp2_encode_header(exec_ctx, &g_compressor, nullptr, 0, &b, &hopt,
- &output);
- grpc_slice_buffer_destroy_internal(exec_ctx, &output);
- grpc_metadata_batch_destroy(exec_ctx, &b);
+ grpc_chttp2_encode_header(&g_compressor, nullptr, 0, &b, &hopt, &output);
+ grpc_slice_buffer_destroy_internal(&output);
+ grpc_metadata_batch_destroy(&b);
GPR_ASSERT(g_compressor.table_size == elem_size + initial_table_size);
gpr_free(e);
}
-static void test_encode_header_size(grpc_exec_ctx* exec_ctx) {
- verify_table_size_change_match_elem_size(exec_ctx, "hello", "world", false);
- verify_table_size_change_match_elem_size(exec_ctx, "hello-bin", "world",
- false);
- verify_table_size_change_match_elem_size(exec_ctx, "true-binary-bin",
+static void test_encode_header_size() {
+ verify_table_size_change_match_elem_size("hello", "world", false);
+ verify_table_size_change_match_elem_size("hello-bin", "world", false);
+ verify_table_size_change_match_elem_size("true-binary-bin",
"I_am_true_binary_value", true);
}
-static void test_interned_key_indexed(grpc_exec_ctx* exec_ctx) {
+static void test_interned_key_indexed() {
int i;
verify_params params = {false, false, true};
- verify(exec_ctx, params, "000009 0104 deadbeef 40 0161 0162 0f2f 0163", 2,
- "a", "b", "a", "c");
+ verify(params, "000009 0104 deadbeef 40 0161 0162 0f2f 0163", 2, "a", "b",
+ "a", "c");
for (i = 0; i < 10; i++) {
- verify(exec_ctx, params, "000008 0104 deadbeef 0f2f 0162 0f2f 0163", 2, "a",
- "b", "a", "c");
+ verify(params, "000008 0104 deadbeef 0f2f 0162 0f2f 0163", 2, "a", "b", "a",
+ "c");
}
}
-static void run_test(void (*test)(grpc_exec_ctx* exec_ctx), const char* name) {
+static void run_test(void (*test)(), const char* name) {
gpr_log(GPR_INFO, "RUN TEST: %s", name);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hpack_compressor_init(&g_compressor);
- test(&exec_ctx);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &g_compressor);
- grpc_exec_ctx_finish(&exec_ctx);
+ test();
+ grpc_chttp2_hpack_compressor_destroy(&g_compressor);
}
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 942f25e0b7..0dfd5ecc2d 100644
--- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
+++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
@@ -29,9 +29,7 @@
bool squelch = true;
bool leak_check = true;
-static void onhdr(grpc_exec_ctx* exec_ctx, void* ud, grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
-}
+static void onhdr(void* ud, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); }
static void dont_log(gpr_log_func_args* args) {}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
@@ -39,13 +37,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
grpc_init();
grpc_chttp2_hpack_parser parser;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_chttp2_hpack_parser_init(&parser);
parser.on_header = onhdr;
GRPC_ERROR_UNREF(grpc_chttp2_hpack_parser_parse(
- &exec_ctx, &parser, grpc_slice_from_static_buffer(data, size)));
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
- grpc_exec_ctx_finish(&exec_ctx);
+ &parser, grpc_slice_from_static_buffer(data, size)));
+ grpc_chttp2_hpack_parser_destroy(&parser);
+
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 82fb20aced..52900c5419 100644
--- a/test/core/transport/chttp2/hpack_parser_test.cc
+++ b/test/core/transport/chttp2/hpack_parser_test.cc
@@ -32,7 +32,7 @@ typedef struct {
va_list args;
} test_checker;
-static void onhdr(grpc_exec_ctx* exec_ctx, void* ud, grpc_mdelem md) {
+static void onhdr(void* ud, grpc_mdelem md) {
const char *ekey, *evalue;
test_checker* chk = static_cast<test_checker*>(ud);
ekey = va_arg(chk->args, char*);
@@ -41,7 +41,7 @@ static void onhdr(grpc_exec_ctx* exec_ctx, void* ud, grpc_mdelem md) {
GPR_ASSERT(evalue);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(md), ekey) == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(md), evalue) == 0);
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
static void test_vector(grpc_chttp2_hpack_parser* parser,
@@ -62,10 +62,9 @@ static void test_vector(grpc_chttp2_hpack_parser* parser,
grpc_slice_unref(input);
for (i = 0; i < nslices; i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_chttp2_hpack_parser_parse(&exec_ctx, parser, slices[i]) ==
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(grpc_chttp2_hpack_parser_parse(parser, slices[i]) ==
GRPC_ERROR_NONE);
- grpc_exec_ctx_finish(&exec_ctx);
}
for (i = 0; i < nslices; i++) {
@@ -80,9 +79,9 @@ static void test_vector(grpc_chttp2_hpack_parser* parser,
static void test_vectors(grpc_slice_split_mode mode) {
grpc_chttp2_hpack_parser parser;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.2.1 */
test_vector(&parser, mode,
"400a 6375 7374 6f6d 2d6b 6579 0d63 7573"
@@ -98,9 +97,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
"password", "secret", NULL);
/* D.2.4 */
test_vector(&parser, mode, "82", ":method", "GET", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.3.1 */
test_vector(&parser, mode,
"8286 8441 0f77 7777 2e65 7861 6d70 6c65"
@@ -118,9 +117,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
":method", "GET", ":scheme", "https", ":path", "/index.html",
":authority", "www.example.com", "custom-key", "custom-value",
NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.4.1 */
test_vector(&parser, mode,
"8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4"
@@ -138,11 +137,11 @@ static void test_vectors(grpc_slice_split_mode mode) {
":method", "GET", ":scheme", "https", ":path", "/index.html",
":authority", "www.example.com", "custom-key", "custom-value",
NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
- grpc_chttp2_hptbl_set_max_bytes(&exec_ctx, &parser.table, 256);
- grpc_chttp2_hptbl_set_current_table_size(&exec_ctx, &parser.table, 256);
+ grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.5.1 */
test_vector(&parser, mode,
"4803 3330 3258 0770 7269 7661 7465 611d"
@@ -172,11 +171,11 @@ static void test_vectors(grpc_slice_split_mode mode) {
"https://www.example.com", "content-encoding", "gzip",
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
- grpc_chttp2_hptbl_set_max_bytes(&exec_ctx, &parser.table, 256);
- grpc_chttp2_hptbl_set_current_table_size(&exec_ctx, &parser.table, 256);
+ grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.6.1 */
test_vector(&parser, mode,
"4882 6402 5885 aec3 771a 4b61 96d0 7abe"
@@ -203,9 +202,7 @@ static void test_vectors(grpc_slice_split_mode mode) {
"https://www.example.com", "content-encoding", "gzip",
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hpack_parser_destroy(&parser);
}
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 ff7c2de538..97e1a02621 100644
--- a/test/core/transport/chttp2/hpack_table_test.cc
+++ b/test/core/transport/chttp2/hpack_table_test.cc
@@ -44,10 +44,10 @@ static void assert_index(const grpc_chttp2_hptbl* tbl, uint32_t idx,
}
static void test_static_lookup(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hptbl tbl;
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
+ grpc_chttp2_hptbl_init(&tbl);
LOG_TEST("test_static_lookup");
assert_index(&tbl, 1, ":authority", "");
@@ -112,8 +112,7 @@ static void test_static_lookup(void) {
assert_index(&tbl, 60, "via", "");
assert_index(&tbl, 61, "www-authenticate", "");
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
static void test_many_additions(void) {
@@ -124,18 +123,17 @@ static void test_many_additions(void) {
LOG_TEST("test_many_additions");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_chttp2_hptbl_init(&tbl);
for (i = 0; i < 100000; i++) {
grpc_mdelem elem;
gpr_asprintf(&key, "K:%d", i);
gpr_asprintf(&value, "VALUE:%d", i);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_copied_string(key),
+ grpc_slice_from_copied_string(value));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
gpr_free(key);
gpr_free(value);
@@ -148,25 +146,23 @@ static void test_many_additions(void) {
}
}
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl* tbl,
const char* key,
const char* value) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ 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(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+
return r;
}
static void test_find(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hptbl tbl;
uint32_t i;
char buffer[32];
@@ -175,21 +171,19 @@ static void test_find(void) {
LOG_TEST("test_find");
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("abc"),
- grpc_slice_from_static_string("xyz"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("abc"),
- grpc_slice_from_static_string("123"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
- elem = grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("x"),
+ grpc_chttp2_hptbl_init(&tbl);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
+ grpc_slice_from_static_string("xyz"));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
+ grpc_slice_from_static_string("123"));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("x"),
grpc_slice_from_static_string("1"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
r = find_simple(&tbl, "abc", "123");
GPR_ASSERT(r.index == 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY);
@@ -238,11 +232,10 @@ static void test_find(void) {
/* overflow the string buffer, check find still works */
for (i = 0; i < 10000; i++) {
int64_ttoa(i, buffer);
- elem = grpc_mdelem_from_slices(&exec_ctx,
- grpc_slice_from_static_string("test"),
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("test"),
grpc_slice_from_copied_string(buffer));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
}
r = find_simple(&tbl, "abc", "123");
@@ -270,8 +263,7 @@ static void test_find(void) {
GPR_ASSERT(r.index != 0);
GPR_ASSERT(r.has_value == 0);
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
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 7a22ec848d..06bb093d32 100644
--- a/test/core/transport/connectivity_state_test.cc
+++ b/test/core/transport/connectivity_state_test.cc
@@ -28,14 +28,13 @@
int g_counter;
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void must_succeed(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(arg == THE_ARG);
g_counter++;
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void must_fail(void* arg, grpc_error* error) {
GPR_ASSERT(error != GRPC_ERROR_NONE);
GPR_ASSERT(arg == THE_ARG);
g_counter++;
@@ -58,7 +57,7 @@ static void test_connectivity_state_name(void) {
static void test_check(void) {
grpc_connectivity_state_tracker tracker;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_error* error;
gpr_log(GPR_DEBUG, "test_check");
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
@@ -66,8 +65,7 @@ static void test_check(void) {
GRPC_CHANNEL_IDLE);
GPR_ASSERT(grpc_connectivity_state_check(&tracker) == GRPC_CHANNEL_IDLE);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
}
static void test_subscribe_then_unsubscribe(void) {
@@ -75,23 +73,21 @@ static void test_subscribe_then_unsubscribe(void) {
grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_fail, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_then_unsubscribe");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
- GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker,
- &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&tracker, &state,
+ closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, nullptr,
- closure);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_connectivity_state_notify_on_state_change(&tracker, nullptr, closure);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 1);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
}
static void test_subscribe_then_destroy(void) {
@@ -99,17 +95,17 @@ static void test_subscribe_then_destroy(void) {
grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_succeed, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_then_destroy");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
- GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker,
- &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&tracker, &state,
+ closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
+
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}
@@ -119,17 +115,17 @@ static void test_subscribe_with_failure_then_destroy(void) {
grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_fail, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_SHUTDOWN;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_with_failure_then_destroy");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_SHUTDOWN, "xxx");
GPR_ASSERT(0 == grpc_connectivity_state_notify_on_state_change(
- &exec_ctx, &tracker, &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ &tracker, &state, closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
+
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 b60a9619fb..e5bdc5901d 100644
--- a/test/core/transport/metadata_test.cc
+++ b/test/core/transport/metadata_test.cc
@@ -60,15 +60,15 @@ static void test_create_metadata(bool intern_keys, bool intern_values) {
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
m1 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
m2 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
m3 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("c"), intern_values));
GPR_ASSERT(grpc_mdelem_eq(m1, m2));
GPR_ASSERT(!grpc_mdelem_eq(m3, m1));
@@ -77,10 +77,10 @@ static void test_create_metadata(bool intern_keys, bool intern_values) {
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(m1), "a") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(m1), "b") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(m3), "c") == 0);
- GRPC_MDELEM_UNREF(&exec_ctx, m1);
- GRPC_MDELEM_UNREF(&exec_ctx, m2);
- GRPC_MDELEM_UNREF(&exec_ctx, m3);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(m1);
+ GRPC_MDELEM_UNREF(m2);
+ GRPC_MDELEM_UNREF(m3);
+
grpc_shutdown();
}
@@ -95,19 +95,15 @@ static void test_create_many_ephemeral_metadata(bool intern_keys,
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* add, and immediately delete a bunch of different elements */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_from_slices(
- &exec_ctx,
- maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
- maybe_intern(grpc_slice_from_copied_string(buffer),
- intern_values)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_from_slices(
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_copied_string(buffer), intern_values)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
}
@@ -121,28 +117,28 @@ static void test_create_many_persistant_metadata(void) {
gpr_log(GPR_INFO, "test_create_many_persistant_metadata");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* add phase */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
created[i] = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("a")),
+ grpc_slice_intern(grpc_slice_from_static_string("a")),
grpc_slice_intern(grpc_slice_from_static_string(buffer)));
}
/* verify phase */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("a")),
+ grpc_slice_intern(grpc_slice_from_static_string("a")),
grpc_slice_intern(grpc_slice_from_static_string(buffer)));
GPR_ASSERT(grpc_mdelem_eq(md, created[i]));
- GRPC_MDELEM_UNREF(&exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
/* cleanup phase */
for (i = 0; i < MANY; i++) {
- GRPC_MDELEM_UNREF(&exec_ctx, created[i]);
+ GRPC_MDELEM_UNREF(created[i]);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
gpr_free(created);
@@ -155,31 +151,25 @@ static void test_spin_creating_the_same_thing(bool intern_keys,
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem a, b, c;
GRPC_MDELEM_UNREF(
- &exec_ctx,
a = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
GRPC_MDELEM_UNREF(
- &exec_ctx,
b = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
GRPC_MDELEM_UNREF(
- &exec_ctx,
c = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
if (intern_keys && intern_values) {
GPR_ASSERT(a.payload == b.payload);
GPR_ASSERT(a.payload == c.payload);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
}
@@ -188,16 +178,16 @@ static void test_identity_laws(bool intern_keys, bool intern_values) {
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem a, b, c;
a = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
b = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
c = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
GPR_ASSERT(grpc_mdelem_eq(a, a));
GPR_ASSERT(grpc_mdelem_eq(b, b));
@@ -216,10 +206,10 @@ static void test_identity_laws(bool intern_keys, bool intern_values) {
GPR_ASSERT(a.payload != c.payload);
GPR_ASSERT(b.payload != c.payload);
}
- GRPC_MDELEM_UNREF(&exec_ctx, a);
- GRPC_MDELEM_UNREF(&exec_ctx, b);
- GRPC_MDELEM_UNREF(&exec_ctx, c);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(a);
+ GRPC_MDELEM_UNREF(b);
+ GRPC_MDELEM_UNREF(c);
+
grpc_shutdown();
}
@@ -235,7 +225,7 @@ static void test_things_stick_around(void) {
gpr_log(GPR_INFO, "test_things_stick_around");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
for (i = 0; i < nstrs; i++) {
gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x", i);
@@ -246,7 +236,7 @@ static void test_things_stick_around(void) {
for (i = 0; i < nstrs; i++) {
grpc_slice_ref_internal(strs[i]);
- grpc_slice_unref_internal(&exec_ctx, strs[i]);
+ grpc_slice_unref_internal(strs[i]);
}
for (i = 0; i < nstrs; i++) {
@@ -258,18 +248,17 @@ static void test_things_stick_around(void) {
}
for (i = 0; i < nstrs; i++) {
- grpc_slice_unref_internal(&exec_ctx, strs[shuf[i]]);
+ grpc_slice_unref_internal(strs[shuf[i]]);
for (j = i + 1; j < nstrs; j++) {
gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x",
shuf[j]);
test = grpc_slice_intern(grpc_slice_from_static_string(buffer));
GPR_ASSERT(grpc_slice_is_equivalent(test, strs[shuf[j]]));
- grpc_slice_unref_internal(&exec_ctx, test);
+ grpc_slice_unref_internal(test);
gpr_free(buffer);
}
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
gpr_free(strs);
gpr_free(shuf);
@@ -282,39 +271,38 @@ static void test_user_data_works(void) {
gpr_log(GPR_INFO, "test_user_data_works");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
ud1 = static_cast<int*>(gpr_malloc(sizeof(int)));
*ud1 = 1;
ud2 = static_cast<int*>(gpr_malloc(sizeof(int)));
*ud2 = 2;
md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_intern(grpc_slice_from_static_string("123")));
grpc_mdelem_set_user_data(md, gpr_free, ud1);
grpc_mdelem_set_user_data(md, gpr_free, ud2);
GPR_ASSERT(grpc_mdelem_get_user_data(md, gpr_free) == ud1);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+
grpc_shutdown();
}
-static void verify_ascii_header_size(grpc_exec_ctx* exec_ctx, const char* key,
- const char* value, bool intern_key,
- bool intern_value) {
+static void verify_ascii_header_size(const char* key, const char* value,
+ bool intern_key, bool intern_value) {
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
+ maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_string(value), intern_value));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
size_t expected_size = 32 + strlen(key) + strlen(value);
GPR_ASSERT(expected_size == elem_size);
- GRPC_MDELEM_UNREF(exec_ctx, elem);
+ GRPC_MDELEM_UNREF(elem);
}
-static void verify_binary_header_size(grpc_exec_ctx* exec_ctx, const char* key,
- const uint8_t* value, size_t value_len,
- bool intern_key, bool intern_value) {
+static void verify_binary_header_size(const char* key, const uint8_t* value,
+ size_t value_len, bool intern_key,
+ bool intern_value) {
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
+ maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_buffer(value, value_len),
intern_value));
GPR_ASSERT(grpc_is_binary_header(GRPC_MDKEY(elem)));
@@ -324,9 +312,9 @@ static void verify_binary_header_size(grpc_exec_ctx* exec_ctx, const char* key,
grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice);
size_t expected_size = 32 + strlen(key) + GRPC_SLICE_LENGTH(base64_encoded);
GPR_ASSERT(expected_size == elem_size);
- grpc_slice_unref_internal(exec_ctx, value_slice);
- grpc_slice_unref_internal(exec_ctx, base64_encoded);
- GRPC_MDELEM_UNREF(exec_ctx, elem);
+ grpc_slice_unref_internal(value_slice);
+ grpc_slice_unref_internal(base64_encoded);
+ GRPC_MDELEM_UNREF(elem);
}
#define BUFFER_SIZE 64
@@ -334,27 +322,23 @@ static void test_mdelem_sizes_in_hpack(bool intern_key, bool intern_value) {
gpr_log(GPR_INFO, "test_mdelem_size: intern_key=%d intern_value=%d",
intern_key, intern_value);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
uint8_t binary_value[BUFFER_SIZE] = {0};
for (uint8_t i = 0; i < BUFFER_SIZE; i++) {
binary_value[i] = i;
}
- verify_ascii_header_size(&exec_ctx, "hello", "world", intern_key,
- intern_value);
- verify_ascii_header_size(&exec_ctx, "hello",
- "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", intern_key,
- intern_value);
- verify_ascii_header_size(&exec_ctx, ":scheme", "http", intern_key,
- intern_value);
+ verify_ascii_header_size("hello", "world", intern_key, intern_value);
+ verify_ascii_header_size("hello", "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ intern_key, intern_value);
+ verify_ascii_header_size(":scheme", "http", intern_key, intern_value);
for (uint8_t i = 0; i < BUFFER_SIZE; i++) {
- verify_binary_header_size(&exec_ctx, "hello-bin", binary_value, i,
- intern_key, intern_value);
+ verify_binary_header_size("hello-bin", binary_value, i, intern_key,
+ intern_value);
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -362,13 +346,13 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
gpr_log(GPR_INFO, "test_static_metadata: dup_key=%d dup_value=%d", dup_key,
dup_value);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) {
grpc_mdelem p = GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[i],
GRPC_MDELEM_STORAGE_STATIC);
grpc_mdelem q =
- grpc_mdelem_from_slices(&exec_ctx, maybe_dup(GRPC_MDKEY(p), dup_key),
+ grpc_mdelem_from_slices(maybe_dup(GRPC_MDKEY(p), dup_key),
maybe_dup(GRPC_MDVALUE(p), dup_value));
GPR_ASSERT(grpc_mdelem_eq(p, q));
if (dup_key || dup_value) {
@@ -376,11 +360,10 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
} else {
GPR_ASSERT(p.payload == q.payload);
}
- GRPC_MDELEM_UNREF(&exec_ctx, p);
- GRPC_MDELEM_UNREF(&exec_ctx, q);
+ GRPC_MDELEM_UNREF(p);
+ GRPC_MDELEM_UNREF(q);
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
diff --git a/test/core/transport/status_conversion_test.cc b/test/core/transport/status_conversion_test.cc
index 7af5d12cb7..2a192e04ef 100644
--- a/test/core/transport/status_conversion_test.cc
+++ b/test/core/transport/status_conversion_test.cc
@@ -22,12 +22,11 @@
#define GRPC_STATUS_TO_HTTP2_ERROR(a, b) \
GPR_ASSERT(grpc_status_to_http2_error(a) == (b))
-#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \
- do { \
- grpc_exec_ctx my_exec_ctx = GRPC_EXEC_CTX_INIT; \
- GPR_ASSERT(grpc_http2_error_to_grpc_status(&my_exec_ctx, a, deadline) == \
- (b)); \
- grpc_exec_ctx_finish(&my_exec_ctx); \
+#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \
+ do { \
+ grpc_core::ExecCtx _local_exec_ctx; \
+ GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b)); \
+ \
} while (0)
#define GRPC_STATUS_TO_HTTP2_STATUS(a, b) \
GPR_ASSERT(grpc_status_to_http2_status(a) == (b))
diff --git a/test/core/transport/stream_owned_slice_test.cc b/test/core/transport/stream_owned_slice_test.cc
index e82df2117d..d25d83c2c6 100644
--- a/test/core/transport/stream_owned_slice_test.cc
+++ b/test/core/transport/stream_owned_slice_test.cc
@@ -22,7 +22,7 @@
#include <grpc/support/log.h>
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
diff --git a/test/core/util/mock_endpoint.cc b/test/core/util/mock_endpoint.cc
index d9545efa49..4b35a581b1 100644
--- a/test/core/util/mock_endpoint.cc
+++ b/test/core/util/mock_endpoint.cc
@@ -40,13 +40,13 @@ typedef struct grpc_mock_endpoint {
grpc_resource_user* resource_user;
} grpc_mock_endpoint;
-static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
} else {
m->on_read = cb;
m->on_read_out = slices;
@@ -54,44 +54,41 @@ static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
gpr_mu_unlock(&m->mu);
}
-static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
for (size_t i = 0; i < slices->count; i++) {
m->on_write(slices->slices[i]);
}
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
}
-static void me_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {}
+static void me_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
-static void me_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void me_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
-static void me_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void me_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
-static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
if (m->on_read) {
- GRPC_CLOSURE_SCHED(exec_ctx, m->on_read,
+ GRPC_CLOSURE_SCHED(m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Endpoint Shutdown", &why, 1));
m->on_read = nullptr;
}
gpr_mu_unlock(&m->mu);
- grpc_resource_user_shutdown(exec_ctx, m->resource_user);
+ grpc_resource_user_shutdown(m->resource_user);
GRPC_ERROR_UNREF(why);
}
-static void me_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void me_destroy(grpc_endpoint* ep) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
grpc_slice_buffer_destroy(&m->read_buffer);
- grpc_resource_user_unref(exec_ctx, m->resource_user);
+ grpc_resource_user_unref(m->resource_user);
gpr_free(m);
}
@@ -134,13 +131,12 @@ grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
return &m->base;
}
-void grpc_mock_endpoint_put_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice slice) {
+void grpc_mock_endpoint_put_read(grpc_endpoint* ep, grpc_slice slice) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
if (m->on_read != nullptr) {
grpc_slice_buffer_add(m->on_read_out, slice);
- GRPC_CLOSURE_SCHED(exec_ctx, m->on_read, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_NONE);
m->on_read = nullptr;
} else {
grpc_slice_buffer_add(&m->read_buffer, slice);
diff --git a/test/core/util/mock_endpoint.h b/test/core/util/mock_endpoint.h
index ccabaf7c3b..6521d3e8e8 100644
--- a/test/core/util/mock_endpoint.h
+++ b/test/core/util/mock_endpoint.h
@@ -23,8 +23,7 @@
grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
grpc_resource_quota* resource_quota);
-void grpc_mock_endpoint_put_read(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* mock_endpoint,
+void grpc_mock_endpoint_put_read(grpc_endpoint* mock_endpoint,
grpc_slice slice);
#endif
diff --git a/test/core/util/passthru_endpoint.cc b/test/core/util/passthru_endpoint.cc
index a9efe22b69..5f127cb960 100644
--- a/test/core/util/passthru_endpoint.cc
+++ b/test/core/util/passthru_endpoint.cc
@@ -49,22 +49,22 @@ struct passthru_endpoint {
int halves;
grpc_passthru_endpoint_stats* stats;
grpc_passthru_endpoint_stats
- dummy_stats; // used if constructor stats == NULL
+ dummy_stats; // used if constructor stats == nullptr
bool shutdown;
half client;
half server;
};
-static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
half* m = (half*)ep;
gpr_mu_lock(&m->parent->mu);
if (m->parent->shutdown) {
GRPC_CLOSURE_SCHED(
- exec_ctx, cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown"));
+ cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown"));
} else if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
} else {
m->on_read = cb;
m->on_read_out = slices;
@@ -77,8 +77,8 @@ static half* other_half(half* h) {
return &h->parent->client;
}
-static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
half* m = other_half((half*)ep);
gpr_mu_lock(&m->parent->mu);
grpc_error* error = GRPC_ERROR_NONE;
@@ -89,7 +89,7 @@ static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
for (size_t i = 0; i < slices->count; i++) {
grpc_slice_buffer_add(m->on_read_out, grpc_slice_copy(slices->slices[i]));
}
- GRPC_CLOSURE_SCHED(exec_ctx, m->on_read, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_NONE);
m->on_read = nullptr;
} else {
for (size_t i = 0; i < slices->count; i++) {
@@ -98,52 +98,49 @@ static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
}
}
gpr_mu_unlock(&m->parent->mu);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ GRPC_CLOSURE_SCHED(cb, error);
}
-static void me_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {}
+static void me_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
-static void me_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void me_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
-static void me_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void me_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
-static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
half* m = (half*)ep;
gpr_mu_lock(&m->parent->mu);
m->parent->shutdown = true;
if (m->on_read) {
GRPC_CLOSURE_SCHED(
- exec_ctx, m->on_read,
+ m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1));
m->on_read = nullptr;
}
m = other_half(m);
if (m->on_read) {
GRPC_CLOSURE_SCHED(
- exec_ctx, m->on_read,
+ m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1));
m->on_read = nullptr;
}
gpr_mu_unlock(&m->parent->mu);
- grpc_resource_user_shutdown(exec_ctx, m->resource_user);
+ grpc_resource_user_shutdown(m->resource_user);
GRPC_ERROR_UNREF(why);
}
-static void me_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void me_destroy(grpc_endpoint* ep) {
passthru_endpoint* p = ((half*)ep)->parent;
gpr_mu_lock(&p->mu);
if (0 == --p->halves) {
gpr_mu_unlock(&p->mu);
gpr_mu_destroy(&p->mu);
- grpc_slice_buffer_destroy_internal(exec_ctx, &p->client.read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &p->server.read_buffer);
- grpc_resource_user_unref(exec_ctx, p->client.resource_user);
- grpc_resource_user_unref(exec_ctx, p->server.resource_user);
+ grpc_slice_buffer_destroy_internal(&p->client.read_buffer);
+ grpc_slice_buffer_destroy_internal(&p->server.read_buffer);
+ grpc_resource_user_unref(p->client.resource_user);
+ grpc_resource_user_unref(p->server.resource_user);
gpr_free(p);
} else {
gpr_mu_unlock(&p->mu);
diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc
index edec50b424..7efa951862 100644
--- a/test/core/util/port_server_client.cc
+++ b/test/core/util/port_server_client.cc
@@ -40,22 +40,19 @@ typedef struct freereq {
int done;
} freereq;
-static void destroy_pops_and_shutdown(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
+static void destroy_pops_and_shutdown(void* p, grpc_error* error) {
grpc_pollset* pollset = grpc_polling_entity_pollset((grpc_polling_entity*)p);
- grpc_pollset_destroy(exec_ctx, pollset);
+ grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
-static void freed_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void freed_port_from_server(void* arg, grpc_error* error) {
freereq* pr = (freereq*)arg;
gpr_mu_lock(pr->mu);
pr->done = 1;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
}
@@ -65,7 +62,7 @@ void grpc_free_port_using_server(int port) {
grpc_httpcli_response rsp;
freereq pr;
char* path;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure* shutdown_closure;
grpc_init();
@@ -87,30 +84,30 @@ void grpc_free_port_using_server(int port) {
grpc_httpcli_context_init(&context);
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/free");
- grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req,
- grpc_exec_ctx_now(&exec_ctx) + 30 * GPR_MS_PER_SEC,
+ grpc_httpcli_get(&context, &pr.pops, resource_quota, &req,
+ grpc_core::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(&exec_ctx, resource_quota);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);
while (!pr.done) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
- &worker,
- grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC))) {
+ grpc_pollset_work(
+ grpc_polling_entity_pollset(&pr.pops), &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
pr.done = 1;
}
}
gpr_mu_unlock(pr.mu);
- grpc_httpcli_context_destroy(&exec_ctx, &context);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
+ grpc_httpcli_context_destroy(&context);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(path);
grpc_http_response_destroy(&rsp);
@@ -127,8 +124,7 @@ typedef struct portreq {
grpc_httpcli_response response;
} portreq;
-static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void got_port_from_server(void* arg, grpc_error* error) {
size_t i;
int port = 0;
portreq* pr = (portreq*)arg;
@@ -154,8 +150,7 @@ static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
pr->port = 0;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
return;
}
@@ -172,12 +167,12 @@ static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
memset(&pr->response, 0, sizeof(pr->response));
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/pick_retry");
- grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, resource_quota, &req,
- grpc_exec_ctx_now(exec_ctx) + 30 * GPR_MS_PER_SEC,
+ grpc_httpcli_get(pr->ctx, &pr->pops, resource_quota, &req,
+ grpc_core::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(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
return;
}
GPR_ASSERT(response);
@@ -191,8 +186,7 @@ static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
pr->port = port;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
}
@@ -200,7 +194,7 @@ int grpc_pick_port_using_server(void) {
grpc_httpcli_context context;
grpc_httpcli_request req;
portreq pr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure* shutdown_closure;
grpc_init();
@@ -223,30 +217,30 @@ int grpc_pick_port_using_server(void) {
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/pick");
grpc_httpcli_get(
- &exec_ctx, &context, &pr.pops, resource_quota, &req,
- grpc_exec_ctx_now(&exec_ctx) + 30 * GPR_MS_PER_SEC,
+ &context, &pr.pops, resource_quota, &req,
+ grpc_core::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(&exec_ctx, resource_quota);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);
while (pr.port == -1) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
- &worker,
- grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC))) {
+ grpc_pollset_work(
+ grpc_polling_entity_pollset(&pr.pops), &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
pr.port = 0;
}
}
gpr_mu_unlock(pr.mu);
grpc_http_response_destroy(&pr.response);
- grpc_httpcli_context_destroy(&exec_ctx, &context);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
+ grpc_httpcli_context_destroy(&context);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
return pr.port;
diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc
index 4775b074eb..bcafc4e898 100644
--- a/test/core/util/reconnect_server.cc
+++ b/test/core/util/reconnect_server.cc
@@ -55,7 +55,7 @@ static void pretty_print_backoffs(reconnect_server* server) {
}
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
+static void on_connect(void* arg, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
@@ -65,9 +65,9 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
timestamp_list* new_tail;
peer = grpc_endpoint_get_peer(tcp);
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
if (peer) {
last_colon = strrchr(peer, ':');
if (server->peer == nullptr) {
diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc
index da34da6fd0..71e6f3af2c 100644
--- a/test/core/util/test_tcp_server.cc
+++ b/test/core/util/test_tcp_server.cc
@@ -33,8 +33,7 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-static void on_server_destroyed(grpc_exec_ctx* exec_ctx, void* data,
- grpc_error* error) {
+static void on_server_destroyed(void* data, grpc_error* error) {
test_tcp_server* server = static_cast<test_tcp_server*>(data);
server->shutdown = 1;
}
@@ -56,51 +55,46 @@ void test_tcp_server_start(test_tcp_server* server, int port) {
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int port_added;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
addr->sin_family = AF_INET;
addr->sin_port = htons((uint16_t)port);
memset(&addr->sin_addr, 0, sizeof(addr->sin_addr));
- grpc_error* error = grpc_tcp_server_create(
- &exec_ctx, &server->shutdown_complete, nullptr, &server->tcp_server);
+ grpc_error* error = grpc_tcp_server_create(&server->shutdown_complete,
+ nullptr, &server->tcp_server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
error =
grpc_tcp_server_add_port(server->tcp_server, &resolved_addr, &port_added);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(port_added == port);
- grpc_tcp_server_start(&exec_ctx, server->tcp_server, &server->pollset, 1,
+ 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(&exec_ctx);
}
void test_tcp_server_poll(test_tcp_server* server, int seconds) {
grpc_pollset_worker* worker = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(seconds));
gpr_mu_lock(server->mu);
- GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, server->pollset, &worker, deadline));
+ GRPC_LOG_IF_ERROR("pollset_work",
+ grpc_pollset_work(server->pollset, &worker, deadline));
gpr_mu_unlock(server->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
-static void finish_pollset(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(arg));
+static void do_nothing(void* arg, grpc_error* error) {}
+static void finish_pollset(void* arg, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(arg));
}
void test_tcp_server_destroy(test_tcp_server* server) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_timespec shutdown_deadline;
grpc_closure do_nothing_cb;
- grpc_tcp_server_unref(&exec_ctx, server->tcp_server);
+ grpc_tcp_server_unref(server->tcp_server);
GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
shutdown_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
@@ -109,10 +103,10 @@ void test_tcp_server_destroy(test_tcp_server* server) {
gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), shutdown_deadline) < 0) {
test_tcp_server_poll(server, 1);
}
- grpc_pollset_shutdown(&exec_ctx, server->pollset,
+ grpc_pollset_shutdown(server->pollset,
GRPC_CLOSURE_CREATE(finish_pollset, server->pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(server->pollset);
grpc_shutdown();
}
diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc
index 4544fb7f49..f95ed62463 100644
--- a/test/core/util/trickle_endpoint.cc
+++ b/test/core/util/trickle_endpoint.cc
@@ -45,24 +45,23 @@ typedef struct {
grpc_closure* write_cb;
} trickle_endpoint;
-static void te_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void te_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_read(exec_ctx, te->wrapped, slices, cb);
+ grpc_endpoint_read(te->wrapped, slices, cb);
}
-static void maybe_call_write_cb_locked(grpc_exec_ctx* exec_ctx,
- trickle_endpoint* te) {
+static void maybe_call_write_cb_locked(trickle_endpoint* te) {
if (te->write_cb != nullptr &&
(te->error != GRPC_ERROR_NONE ||
te->write_buffer.length <= WRITE_BUFFER_SIZE)) {
- GRPC_CLOSURE_SCHED(exec_ctx, te->write_cb, GRPC_ERROR_REF(te->error));
+ GRPC_CLOSURE_SCHED(te->write_cb, GRPC_ERROR_REF(te->error));
te->write_cb = nullptr;
}
}
-static void te_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
GPR_ASSERT(te->write_cb == nullptr);
@@ -74,47 +73,44 @@ static void te_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
grpc_slice_copy(slices->slices[i]));
}
te->write_cb = cb;
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
gpr_mu_unlock(&te->mu);
}
-static void te_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {
+static void te_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_add_to_pollset(exec_ctx, te->wrapped, pollset);
+ grpc_endpoint_add_to_pollset(te->wrapped, pollset);
}
-static void te_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void te_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_add_to_pollset_set(exec_ctx, te->wrapped, pollset_set);
+ grpc_endpoint_add_to_pollset_set(te->wrapped, pollset_set);
}
-static void te_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void te_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_delete_from_pollset_set(exec_ctx, te->wrapped, pollset_set);
+ grpc_endpoint_delete_from_pollset_set(te->wrapped, pollset_set);
}
-static void te_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void te_shutdown(grpc_endpoint* ep, grpc_error* why) {
trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
if (te->error == GRPC_ERROR_NONE) {
te->error = GRPC_ERROR_REF(why);
}
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
gpr_mu_unlock(&te->mu);
- grpc_endpoint_shutdown(exec_ctx, te->wrapped, why);
+ grpc_endpoint_shutdown(te->wrapped, why);
}
-static void te_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void te_destroy(grpc_endpoint* ep) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_destroy(exec_ctx, te->wrapped);
+ grpc_endpoint_destroy(te->wrapped);
gpr_mu_destroy(&te->mu);
- grpc_slice_buffer_destroy_internal(exec_ctx, &te->write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &te->writing_buffer);
+ grpc_slice_buffer_destroy_internal(&te->write_buffer);
+ grpc_slice_buffer_destroy_internal(&te->writing_buffer);
GRPC_ERROR_UNREF(te->error);
gpr_free(te);
}
@@ -134,8 +130,7 @@ static int te_get_fd(grpc_endpoint* ep) {
return grpc_endpoint_get_fd(te->wrapped);
}
-static void te_finish_write(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void te_finish_write(void* arg, grpc_error* error) {
trickle_endpoint* te = (trickle_endpoint*)arg;
gpr_mu_lock(&te->mu);
te->writing = false;
@@ -173,8 +168,7 @@ static double ts2dbl(gpr_timespec s) {
return (double)s.tv_sec + 1e-9 * (double)s.tv_nsec;
}
-size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep) {
+size_t grpc_trickle_endpoint_trickle(grpc_endpoint* ep) {
trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
if (!te->writing && te->write_buffer.length > 0) {
@@ -189,9 +183,9 @@ size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx,
te->writing = true;
te->last_write = now;
grpc_endpoint_write(
- exec_ctx, te->wrapped, &te->writing_buffer,
+ te->wrapped, &te->writing_buffer,
GRPC_CLOSURE_CREATE(te_finish_write, te, grpc_schedule_on_exec_ctx));
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
}
}
size_t backlog = te->write_buffer.length;
diff --git a/test/core/util/trickle_endpoint.h b/test/core/util/trickle_endpoint.h
index 11c113bda8..cd07de905a 100644
--- a/test/core/util/trickle_endpoint.h
+++ b/test/core/util/trickle_endpoint.h
@@ -25,8 +25,7 @@ grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
double bytes_per_second);
/* Allow up to \a bytes through the endpoint. Returns the new backlog. */
-size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* endpoint);
+size_t grpc_trickle_endpoint_trickle(grpc_endpoint* endpoint);
size_t grpc_trickle_get_backlog(grpc_endpoint* endpoint);
diff --git a/test/cpp/common/channel_filter_test.cc b/test/cpp/common/channel_filter_test.cc
index 638518107b..7bdd53f9e7 100644
--- a/test/cpp/common/channel_filter_test.cc
+++ b/test/cpp/common/channel_filter_test.cc
@@ -28,7 +28,7 @@ class MyChannelData : public ChannelData {
public:
MyChannelData() {}
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ grpc_error* Init(grpc_channel_element* elem,
grpc_channel_element_args* args) override {
(void)args->channel_args; // Make sure field is available.
return GRPC_ERROR_NONE;
@@ -39,7 +39,7 @@ class MyCallData : public CallData {
public:
MyCallData() {}
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+ grpc_error* Init(grpc_call_element* elem,
const grpc_call_element_args* args) override {
(void)args->path; // Make sure field is available.
return GRPC_ERROR_NONE;
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc
index f8bb12fde1..f2f3cc3425 100644
--- a/test/cpp/end2end/client_lb_end2end_test.cc
+++ b/test/cpp/end2end/client_lb_end2end_test.cc
@@ -112,13 +112,13 @@ class ClientLbEnd2endTest : public ::testing::Test {
}
void SetNextResolution(const std::vector<int>& ports) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_lb_addresses* addresses =
grpc_lb_addresses_create(ports.size(), nullptr);
for (size_t i = 0; i < ports.size(); ++i) {
char* lb_uri_str;
gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", ports[i]);
- grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(addresses, i, lb_uri,
false /* is balancer */,
@@ -130,11 +130,10 @@ class ClientLbEnd2endTest : public ::testing::Test {
grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args* fake_result =
grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1);
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator_, fake_result);
- grpc_channel_args_destroy(&exec_ctx, fake_result);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_fake_resolver_response_generator_set_response(response_generator_,
+ fake_result);
+ grpc_channel_args_destroy(fake_result);
+ grpc_lb_addresses_destroy(addresses);
}
void ResetStub(const grpc::string& lb_policy_name = "") {
diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc
index f260ea0016..c4430379db 100644
--- a/test/cpp/end2end/filter_end2end_test.cc
+++ b/test/cpp/end2end/filter_end2end_test.cc
@@ -100,7 +100,7 @@ int GetCallCounterValue() {
class ChannelDataImpl : public ChannelData {
public:
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ grpc_error* Init(grpc_channel_element* elem,
grpc_channel_element_args* args) {
IncrementConnectionCounter();
return GRPC_ERROR_NONE;
@@ -109,13 +109,12 @@ class ChannelDataImpl : public ChannelData {
class CallDataImpl : public CallData {
public:
- void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ void StartTransportStreamOpBatch(grpc_call_element* elem,
TransportStreamOpBatch* op) override {
// Incrementing the counter could be done from Init(), but we want
// to test that the individual methods are actually called correctly.
if (op->recv_initial_metadata() != nullptr) IncrementCallCounter();
- grpc_call_next_op(exec_ctx, elem, op->op());
+ grpc_call_next_op(elem, op->op());
}
};
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc
index c15ab88da1..c5c53b8b8a 100644
--- a/test/cpp/end2end/grpclb_end2end_test.cc
+++ b/test/cpp/end2end/grpclb_end2end_test.cc
@@ -451,13 +451,13 @@ class GrpclbEnd2endTest : public ::testing::Test {
};
void SetNextResolution(const std::vector<AddressData>& address_data) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_lb_addresses* addresses =
grpc_lb_addresses_create(address_data.size(), nullptr);
for (size_t i = 0; i < address_data.size(); ++i) {
char* lb_uri_str;
gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", address_data[i].port);
- grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(
addresses, i, lb_uri, address_data[i].is_balancer,
@@ -467,10 +467,9 @@ class GrpclbEnd2endTest : public ::testing::Test {
}
grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args fake_result = {1, &fake_addresses};
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator_, &fake_result);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_fake_resolver_response_generator_set_response(response_generator_,
+ &fake_result);
+ grpc_lb_addresses_destroy(addresses);
}
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 ca846c72fd..792c82639c 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -562,7 +562,7 @@ static void perform_request(client_fixture* cf) {
#define BALANCERS_NAME "lb.name"
static void setup_client(const server_fixture* lb_server,
const server_fixture* backends, client_fixture* cf) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
char* expected_target_names = nullptr;
const char* backends_name = lb_server->servers_hostport;
@@ -574,7 +574,7 @@ static void setup_client(const server_fixture* lb_server,
grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, nullptr);
char* lb_uri_str;
gpr_asprintf(&lb_uri_str, "ipv4:%s", lb_server->servers_hostport);
- grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(addresses, 0, lb_uri, true,
lb_server->balancer_name, nullptr);
@@ -586,7 +586,7 @@ static void setup_client(const server_fixture* lb_server,
grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args* fake_result =
grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
+ grpc_lb_addresses_destroy(addresses);
const grpc_arg new_args[] = {
grpc_fake_transport_expected_targets_arg(expected_target_names),
@@ -601,13 +601,12 @@ static void setup_client(const server_fixture* lb_server,
grpc_fake_transport_security_credentials_create();
cf->client =
grpc_secure_channel_create(fake_creds, cf->server_uri, args, nullptr);
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, fake_result);
- grpc_channel_args_destroy(&exec_ctx, fake_result);
- grpc_channel_credentials_unref(&exec_ctx, fake_creds);
- grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ fake_result);
+ grpc_channel_args_destroy(fake_result);
+ grpc_channel_credentials_unref(fake_creds);
+ grpc_channel_args_destroy(args);
grpc_fake_resolver_response_generator_unref(response_generator);
- grpc_exec_ctx_finish(&exec_ctx);
}
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 a45c577320..b17f79613a 100644
--- a/test/cpp/microbenchmarks/bm_call_create.cc
+++ b/test/cpp/microbenchmarks/bm_call_create.cc
@@ -311,12 +311,9 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) {
}
BENCHMARK(BM_LameChannelCallCreateCoreSeparateBatch);
-static void FilterDestroy(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- gpr_free(arg);
-}
+static void FilterDestroy(void* arg, grpc_error* error) { gpr_free(arg); }
-static void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void DoNothing(void* arg, grpc_error* error) {}
class FakeClientChannelFactory : public grpc_client_channel_factory {
public:
@@ -324,15 +321,12 @@ class FakeClientChannelFactory : public grpc_client_channel_factory {
private:
static void NoRef(grpc_client_channel_factory* factory) {}
- static void NoUnref(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory) {}
- static grpc_subchannel* CreateSubchannel(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory,
+ static void NoUnref(grpc_client_channel_factory* factory) {}
+ static grpc_subchannel* CreateSubchannel(grpc_client_channel_factory* factory,
const grpc_subchannel_args* args) {
return nullptr;
}
- static grpc_channel* CreateClientChannel(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory,
+ static grpc_channel* CreateClientChannel(grpc_client_channel_factory* factory,
const char* target,
grpc_client_channel_type type,
const grpc_channel_args* args) {
@@ -366,36 +360,32 @@ struct Fixture {
namespace dummy_filter {
-static void StartTransportStreamOp(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void StartTransportStreamOp(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {}
-static void StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void StartTransportOp(grpc_channel_element* elem,
grpc_transport_op* op) {}
-static grpc_error* InitCallElem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* InitCallElem(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent) {}
-static void DestroyCallElem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void DestroyCallElem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_sched_closure) {}
-grpc_error* InitChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+grpc_error* InitChannelElem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-void DestroyChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {}
+void DestroyChannelElem(grpc_channel_element* elem) {}
-void GetChannelInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+void GetChannelInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {}
static const grpc_channel_filter dummy_filter = {StartTransportStreamOp,
@@ -422,41 +412,38 @@ size_t sizeof_stream; /* = sizeof(transport stream) */
const char* name;
/* implementation of grpc_transport_init_stream */
-int InitStream(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_stream_refcount* refcount,
- const void* server_data, gpr_arena* arena) {
+int InitStream(grpc_transport* self, grpc_stream* stream,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
return 0;
}
/* implementation of grpc_transport_set_pollset */
-void SetPollset(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_pollset* pollset) {}
+void SetPollset(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset* pollset) {}
/* implementation of grpc_transport_set_pollset */
-void SetPollsetSet(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_pollset_set* pollset_set) {}
+void SetPollsetSet(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset_set* pollset_set) {}
/* implementation of grpc_transport_perform_stream_op */
-void PerformStreamOp(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_transport_stream_op_batch* op) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_NONE);
+void PerformStreamOp(grpc_transport* self, grpc_stream* stream,
+ grpc_transport_stream_op_batch* op) {
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_NONE);
}
/* implementation of grpc_transport_perform_op */
-void PerformOp(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_transport_op* op) {}
+void PerformOp(grpc_transport* self, grpc_transport_op* op) {}
/* implementation of grpc_transport_destroy_stream */
-void DestroyStream(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_closure* then_sched_closure) {}
+void DestroyStream(grpc_transport* self, grpc_stream* stream,
+ grpc_closure* then_sched_closure) {}
/* implementation of grpc_transport_destroy */
-void Destroy(grpc_exec_ctx* exec_ctx, grpc_transport* self) {}
+void Destroy(grpc_transport* self) {}
/* implementation of grpc_transport_get_endpoint */
-grpc_endpoint* GetEndpoint(grpc_exec_ctx* exec_ctx, grpc_transport* self) {
- return nullptr;
-}
+grpc_endpoint* GetEndpoint(grpc_transport* self) { return nullptr; }
static const grpc_transport_vtable dummy_transport_vtable = {
0, "dummy_http2", InitStream,
@@ -472,8 +459,8 @@ class NoOp {
public:
class Op {
public:
- Op(grpc_exec_ctx* exec_ctx, NoOp* p, grpc_call_stack* s) {}
- void Finish(grpc_exec_ctx* exec_ctx) {}
+ Op(NoOp* p, grpc_call_stack* s) {}
+ void Finish() {}
};
};
@@ -489,13 +476,11 @@ class SendEmptyMetadata {
class Op {
public:
- Op(grpc_exec_ctx* exec_ctx, SendEmptyMetadata* p, grpc_call_stack* s) {
+ Op(SendEmptyMetadata* p, grpc_call_stack* s) {
grpc_metadata_batch_init(&batch_);
p->op_payload_.send_initial_metadata.send_initial_metadata = &batch_;
}
- void Finish(grpc_exec_ctx* exec_ctx) {
- grpc_metadata_batch_destroy(exec_ctx, &batch_);
- }
+ void Finish() { grpc_metadata_batch_destroy(&batch_); }
private:
grpc_metadata_batch batch_;
@@ -536,20 +521,20 @@ static void BM_IsolatedFilter(benchmark::State& state) {
label << " #has_dummy_filter";
}
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
size_t channel_size = grpc_channel_stack_size(
filters.size() == 0 ? nullptr : &filters[0], filters.size());
grpc_channel_stack* channel_stack =
static_cast<grpc_channel_stack*>(gpr_zalloc(channel_size));
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"channel_stack_init",
- grpc_channel_stack_init(&exec_ctx, 1, FilterDestroy, channel_stack,
- &filters[0], filters.size(), &channel_args,
+ grpc_channel_stack_init(1, FilterDestroy, channel_stack, &filters[0],
+ filters.size(), &channel_args,
fixture.flags & REQUIRES_TRANSPORT
? &dummy_transport::dummy_transport
: nullptr,
"CHANNEL", channel_stack)));
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::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;
@@ -568,12 +553,12 @@ static void BM_IsolatedFilter(benchmark::State& state) {
call_args.arena = gpr_arena_create(kArenaSize);
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
- GRPC_ERROR_UNREF(grpc_call_stack_init(&exec_ctx, channel_stack, 1,
- DoNothing, nullptr, &call_args));
- typename TestOp::Op op(&exec_ctx, &test_op_data, call_stack);
- grpc_call_stack_destroy(&exec_ctx, call_stack, &final_info, nullptr);
- op.Finish(&exec_ctx);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_ERROR_UNREF(
+ grpc_call_stack_init(channel_stack, 1, DoNothing, nullptr, &call_args));
+ typename TestOp::Op op(&test_op_data, call_stack);
+ grpc_call_stack_destroy(call_stack, &final_info, nullptr);
+ op.Finish();
+ grpc_core::ExecCtx::Get()->Flush();
// recreate arena every 64k iterations to avoid oom
if (0 == (state.iterations() & 0xffff)) {
gpr_arena_destroy(call_args.arena);
@@ -581,8 +566,8 @@ static void BM_IsolatedFilter(benchmark::State& state) {
}
}
gpr_arena_destroy(call_args.arena);
- grpc_channel_stack_destroy(&exec_ctx, channel_stack);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_stack_destroy(channel_stack);
+
gpr_free(channel_stack);
gpr_free(call_stack);
@@ -632,59 +617,55 @@ typedef struct {
grpc_call_combiner* call_combiner;
} call_data;
-static void StartTransportStreamOp(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void StartTransportStreamOp(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
call_data* calld = static_cast<call_data*>(elem->call_data);
if (op->recv_initial_metadata) {
GRPC_CALL_COMBINER_START(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE, "recv_initial_metadata");
}
if (op->recv_message) {
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_START(calld->call_combiner,
op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE, "recv_message");
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_NONE);
}
-static void StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void StartTransportOp(grpc_channel_element* elem,
grpc_transport_op* op) {
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
GRPC_ERROR_UNREF(op->disconnect_with_error);
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
-static grpc_error* InitCallElem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* InitCallElem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = static_cast<call_data*>(elem->call_data);
calld->call_combiner = args->call_combiner;
return GRPC_ERROR_NONE;
}
-static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent) {}
-static void DestroyCallElem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void DestroyCallElem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_sched_closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, then_sched_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(then_sched_closure, GRPC_ERROR_NONE);
}
-grpc_error* InitChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+grpc_error* InitChannelElem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-void DestroyChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {}
+void DestroyChannelElem(grpc_channel_element* elem) {}
-void GetChannelInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+void GetChannelInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {}
static const grpc_channel_filter isolated_call_filter = {
@@ -711,10 +692,8 @@ class IsolatedCallFixture : public TrackCounters {
builder, &isolated_call_filter::isolated_call_filter, nullptr,
nullptr));
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- channel_ = grpc_channel_create_with_builder(&exec_ctx, builder,
- GRPC_CLIENT_CHANNEL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ channel_ = grpc_channel_create_with_builder(builder, GRPC_CLIENT_CHANNEL);
}
cq_ = grpc_completion_queue_create_for_next(nullptr);
}
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index 3fff8b02d6..6b6b441d93 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -50,22 +50,22 @@ static grpc_slice MakeSlice(std::vector<uint8_t> bytes) {
static void BM_HpackEncoderInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hpack_compressor c;
while (state.KeepRunning()) {
grpc_chttp2_hpack_compressor_init(&c);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_HpackEncoderInitDestroy);
static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_millis saved_now = grpc_exec_ctx_now(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_millis saved_now = grpc_core::ExecCtx::Get()->Now();
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
@@ -85,14 +85,13 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
(size_t)1024,
&stats,
};
- grpc_chttp2_encode_header(&exec_ctx, &c, nullptr, 0, &b, &hopt, &outbuf);
- grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
+ grpc_slice_buffer_reset_and_unref_internal(&outbuf);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_metadata_batch_destroy(&exec_ctx, &b);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_metadata_batch_destroy(&b);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_slice_buffer_destroy_internal(&outbuf);
std::ostringstream label;
label << "framing_bytes/iter:"
@@ -109,17 +108,16 @@ BENCHMARK(BM_HpackEncoderEncodeDeadline);
template <class Fixture>
static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
static bool logged_representative_output = false;
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
- std::vector<grpc_mdelem> elems = Fixture::GetElems(&exec_ctx);
+ std::vector<grpc_mdelem> elems = Fixture::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(&exec_ctx, &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
grpc_chttp2_hpack_compressor c;
@@ -136,7 +134,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
(size_t)state.range(1),
&stats,
};
- grpc_chttp2_encode_header(&exec_ctx, &c, nullptr, 0, &b, &hopt, &outbuf);
+ grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
if (!logged_representative_output && state.iterations() > 3) {
logged_representative_output = true;
for (size_t i = 0; i < outbuf.count; i++) {
@@ -145,13 +143,12 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
gpr_free(s);
}
}
- grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_slice_buffer_reset_and_unref_internal(&outbuf);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_metadata_batch_destroy(&exec_ctx, &b);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_metadata_batch_destroy(&b);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_slice_buffer_destroy_internal(&outbuf);
std::ostringstream label;
label << "framing_bytes/iter:"
@@ -169,15 +166,13 @@ namespace hpack_encoder_fixtures {
class EmptyBatch {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
- return {};
- }
+ static std::vector<grpc_mdelem> GetElems() { return {}; }
};
class SingleStaticElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE};
}
};
@@ -185,9 +180,9 @@ class SingleStaticElem {
class SingleInternedElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_intern(grpc_slice_from_static_string("def")))};
}
};
@@ -196,10 +191,10 @@ template <int kLength, bool kTrueBinary>
class SingleInternedBinaryElem {
public:
static constexpr bool kEnableTrueBinary = kTrueBinary;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
grpc_slice bytes = MakeBytes();
std::vector<grpc_mdelem> out = {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc-bin")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc-bin")),
grpc_slice_intern(bytes))};
grpc_slice_unref(bytes);
return out;
@@ -218,9 +213,9 @@ class SingleInternedBinaryElem {
class SingleInternedKeyElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_from_static_string("def"))};
}
};
@@ -228,9 +223,8 @@ class SingleInternedKeyElem {
class SingleNonInternedElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
- return {grpc_mdelem_from_slices(exec_ctx,
- grpc_slice_from_static_string("abc"),
+ static std::vector<grpc_mdelem> GetElems() {
+ return {grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
grpc_slice_from_static_string("def"))};
}
};
@@ -239,9 +233,9 @@ template <int kLength, bool kTrueBinary>
class SingleNonInternedBinaryElem {
public:
static constexpr bool kEnableTrueBinary = kTrueBinary;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
- return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_from_static_string("abc-bin"), MakeBytes())};
+ static std::vector<grpc_mdelem> GetElems() {
+ return {grpc_mdelem_from_slices(grpc_slice_from_static_string("abc-bin"),
+ MakeBytes())};
}
private:
@@ -257,21 +251,21 @@ class SingleNonInternedBinaryElem {
class RepresentativeClientInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {
GRPC_MDELEM_SCHEME_HTTP,
GRPC_MDELEM_METHOD_POST,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH,
+ GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(
"foo.test.google.fr:1234"))),
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
GRPC_MDELEM_TE_TRAILERS,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
grpc_slice_intern(grpc_slice_from_static_string(
"grpc-c/3.0.0-dev (linux; chttp2; green)")))};
}
@@ -283,18 +277,18 @@ class RepresentativeClientInitialMetadata {
class MoreRepresentativeClientInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {
GRPC_MDELEM_SCHEME_HTTP,
GRPC_MDELEM_METHOD_POST,
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH,
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string(
"/grpc.test.FooService/BarMethod"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(
"foo.test.google.fr:1234"))),
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_TRACE_BIN,
+ GRPC_MDSTR_GRPC_TRACE_BIN,
grpc_slice_from_static_string("\x00\x01\x02\x03\x04\x05\x06\x07\x08"
"\x09\x0a\x0b\x0c\x0d\x0e\x0f"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18"
@@ -303,7 +297,7 @@ class MoreRepresentativeClientInitialMetadata {
"\x29\x2a\x2b\x2c\x2d\x2e\x2f"
"\x30")),
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_TAGS_BIN,
+ GRPC_MDSTR_GRPC_TAGS_BIN,
grpc_slice_from_static_string("\x00\x01\x02\x03\x04\x05\x06\x07\x08"
"\x09\x0a\x0b\x0c\x0d\x0e\x0f"
"\x10\x11\x12\x13")),
@@ -311,7 +305,7 @@ class MoreRepresentativeClientInitialMetadata {
GRPC_MDELEM_TE_TRAILERS,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
grpc_slice_intern(grpc_slice_from_static_string(
"grpc-c/3.0.0-dev (linux; chttp2; green)")))};
}
@@ -320,7 +314,7 @@ class MoreRepresentativeClientInitialMetadata {
class RepresentativeServerInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_STATUS_200,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP};
@@ -330,7 +324,7 @@ class RepresentativeServerInitialMetadata {
class RepresentativeServerTrailingMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_GRPC_STATUS_0};
}
};
@@ -431,48 +425,45 @@ BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
static void BM_HpackParserInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hpack_parser p;
while (state.KeepRunning()) {
- grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_chttp2_hpack_parser_init(&p);
+ grpc_chttp2_hpack_parser_destroy(&p);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_HpackParserInitDestroy);
-static void UnrefHeader(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
+static void UnrefHeader(void* user_data, grpc_mdelem md) {
+ GRPC_MDELEM_UNREF(md);
}
-template <class Fixture, void (*OnHeader)(grpc_exec_ctx*, void*, grpc_mdelem)>
+template <class Fixture, void (*OnHeader)(void*, grpc_mdelem)>
static void BM_HpackParserParseHeader(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
std::vector<grpc_slice> init_slices = Fixture::GetInitSlices();
std::vector<grpc_slice> benchmark_slices = Fixture::GetBenchmarkSlices();
grpc_chttp2_hpack_parser p;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
+ grpc_chttp2_hpack_parser_init(&p);
p.on_header = OnHeader;
p.on_header_user_data = nullptr;
for (auto slice : init_slices) {
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
while (state.KeepRunning()) {
for (auto slice : benchmark_slices) {
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::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(&exec_ctx, &p);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hpack_parser_destroy(&p);
+
track_counters.Finish(state);
}
@@ -769,8 +760,7 @@ class RepresentativeServerTrailingMetadata {
static void free_timeout(void* p) { gpr_free(p); }
// New implementation.
-static void OnHeaderNew(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_mdelem md) {
+static void OnHeaderNew(void* user_data, grpc_mdelem md) {
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
grpc_millis* cached_timeout =
static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
@@ -793,7 +783,7 @@ static void OnHeaderNew(grpc_exec_ctx* exec_ctx, void* user_data,
}
}
benchmark::DoNotOptimize(timeout);
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
} else {
GPR_ASSERT(0);
}
diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
index b95ee0cc01..044417830f 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
@@ -58,7 +58,7 @@ class DummyEndpoint : public grpc_endpoint {
ru_ = grpc_resource_user_create(Library::get().rq(), "dummy_endpoint");
}
- void PushInput(grpc_exec_ctx* exec_ctx, grpc_slice slice) {
+ void PushInput(grpc_slice slice) {
if (read_cb_ == nullptr) {
GPR_ASSERT(!have_slice_);
buffered_slice_ = slice;
@@ -66,7 +66,7 @@ class DummyEndpoint : public grpc_endpoint {
return;
}
grpc_slice_buffer_add(slices_, slice);
- GRPC_CLOSURE_SCHED(exec_ctx, read_cb_, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(read_cb_, GRPC_ERROR_NONE);
read_cb_ = nullptr;
}
@@ -77,50 +77,45 @@ class DummyEndpoint : public grpc_endpoint {
bool have_slice_ = false;
grpc_slice buffered_slice_;
- void QueueRead(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* slices,
- grpc_closure* cb) {
+ void QueueRead(grpc_slice_buffer* slices, grpc_closure* cb) {
GPR_ASSERT(read_cb_ == nullptr);
if (have_slice_) {
have_slice_ = false;
grpc_slice_buffer_add(slices, buffered_slice_);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
return;
}
read_cb_ = cb;
slices_ = slices;
}
- static void read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
- static_cast<DummyEndpoint*>(ep)->QueueRead(exec_ctx, slices, cb);
+ static void read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ static_cast<DummyEndpoint*>(ep)->QueueRead(slices, cb);
}
- static void write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ static void write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
}
static grpc_workqueue* get_workqueue(grpc_endpoint* ep) { return nullptr; }
- static void add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {}
+ static void add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
- static void add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset_set* pollset) {}
+ static void add_to_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pollset) {
+ }
- static void delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+ static void delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
- static void shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
- grpc_resource_user_shutdown(exec_ctx, static_cast<DummyEndpoint*>(ep)->ru_);
- GRPC_CLOSURE_SCHED(exec_ctx, static_cast<DummyEndpoint*>(ep)->read_cb_,
- why);
+ static void shutdown(grpc_endpoint* ep, grpc_error* why) {
+ grpc_resource_user_shutdown(static_cast<DummyEndpoint*>(ep)->ru_);
+ GRPC_CLOSURE_SCHED(static_cast<DummyEndpoint*>(ep)->read_cb_, why);
}
- static void destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
- grpc_resource_user_unref(exec_ctx, static_cast<DummyEndpoint*>(ep)->ru_);
+ static void destroy(grpc_endpoint* ep) {
+ grpc_resource_user_unref(static_cast<DummyEndpoint*>(ep)->ru_);
delete static_cast<DummyEndpoint*>(ep);
}
@@ -136,29 +131,24 @@ class Fixture {
Fixture(const grpc::ChannelArguments& args, bool client) {
grpc_channel_args c_args = args.c_channel_args();
ep_ = new DummyEndpoint;
- t_ = grpc_create_chttp2_transport(exec_ctx(), &c_args, ep_, client);
- grpc_chttp2_transport_start_reading(exec_ctx(), t_, nullptr);
+ t_ = grpc_create_chttp2_transport(&c_args, ep_, client);
+ grpc_chttp2_transport_start_reading(t_, nullptr);
FlushExecCtx();
}
- void FlushExecCtx() { grpc_exec_ctx_flush(&exec_ctx_); }
+ void FlushExecCtx() { grpc_core::ExecCtx::Get()->Flush(); }
- ~Fixture() {
- grpc_transport_destroy(&exec_ctx_, t_);
- grpc_exec_ctx_finish(&exec_ctx_);
- }
+ ~Fixture() { grpc_transport_destroy(t_); }
grpc_chttp2_transport* chttp2_transport() {
return reinterpret_cast<grpc_chttp2_transport*>(t_);
}
grpc_transport* transport() { return t_; }
- grpc_exec_ctx* exec_ctx() { return &exec_ctx_; }
- void PushInput(grpc_slice slice) { ep_->PushInput(exec_ctx(), slice); }
+ void PushInput(grpc_slice slice) { ep_->PushInput(slice); }
private:
DummyEndpoint* ep_;
- grpc_exec_ctx exec_ctx_ = GRPC_EXEC_CTX_INIT;
grpc_transport* t_;
};
@@ -175,8 +165,8 @@ std::unique_ptr<Closure> MakeClosure(
GRPC_CLOSURE_INIT(this, Execute, this, sched);
}
F f_;
- static void Execute(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- static_cast<C*>(arg)->f_(exec_ctx, error);
+ static void Execute(void* arg, grpc_error* error) {
+ static_cast<C*>(arg)->f_(error);
}
};
return std::unique_ptr<Closure>(new C(f, sched));
@@ -188,8 +178,8 @@ grpc_closure* MakeOnceClosure(
struct C : public grpc_closure {
C(const F& f) : f_(f) {}
F f_;
- static void Execute(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- static_cast<C*>(arg)->f_(exec_ctx, error);
+ static void Execute(void* arg, grpc_error* error) {
+ static_cast<C*>(arg)->f_(error);
delete static_cast<C*>(arg);
}
};
@@ -220,22 +210,22 @@ class Stream {
gpr_arena_destroy(arena_);
arena_ = gpr_arena_create(4096);
}
- grpc_transport_init_stream(f_->exec_ctx(), f_->transport(),
+ grpc_transport_init_stream(f_->transport(),
static_cast<grpc_stream*>(stream_), &refcount_,
nullptr, arena_);
}
- void DestroyThen(grpc_exec_ctx* exec_ctx, grpc_closure* closure) {
+ void DestroyThen(grpc_closure* closure) {
destroy_closure_ = closure;
#ifndef NDEBUG
- grpc_stream_unref(exec_ctx, &refcount_, "DestroyThen");
+ grpc_stream_unref(&refcount_, "DestroyThen");
#else
- grpc_stream_unref(exec_ctx, &refcount_);
+ grpc_stream_unref(&refcount_);
#endif
}
- void Op(grpc_exec_ctx* exec_ctx, grpc_transport_stream_op_batch* op) {
- grpc_transport_perform_stream_op(exec_ctx, f_->transport(),
+ void Op(grpc_transport_stream_op_batch* op) {
+ grpc_transport_perform_stream_op(f_->transport(),
static_cast<grpc_stream*>(stream_), op);
}
@@ -244,10 +234,9 @@ class Stream {
}
private:
- static void FinishDestroy(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+ static void FinishDestroy(void* arg, grpc_error* error) {
auto stream = static_cast<Stream*>(arg);
- grpc_transport_destroy_stream(exec_ctx, stream->f_->transport(),
+ grpc_transport_destroy_stream(stream->f_->transport(),
static_cast<grpc_stream*>(stream->stream_),
stream->destroy_closure_);
gpr_event_set(&stream->done_, (void*)1);
@@ -268,6 +257,7 @@ class Stream {
static void BM_StreamCreateDestroy(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
grpc_transport_stream_op_batch op;
@@ -276,14 +266,13 @@ static void BM_StreamCreateDestroy(benchmark::State& state) {
op.cancel_stream = true;
op.payload = &op_payload;
op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- std::unique_ptr<Closure> next =
- MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (!state.KeepRunning()) return;
- s.Init(state);
- s.Op(exec_ctx, &op);
- s.DestroyThen(exec_ctx, next.get());
- });
- GRPC_CLOSURE_RUN(f.exec_ctx(), next.get(), GRPC_ERROR_NONE);
+ std::unique_ptr<Closure> next = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) return;
+ s.Init(state);
+ s.Op(&op);
+ s.DestroyThen(next.get());
+ });
+ GRPC_CLOSURE_RUN(next.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
track_counters.Finish(state);
}
@@ -291,21 +280,21 @@ BENCHMARK(BM_StreamCreateDestroy);
class RepresentativeClientInitialMetadata {
public:
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {
GRPC_MDELEM_SCHEME_HTTP,
GRPC_MDELEM_METHOD_POST,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH,
+ GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(
"foo.test.google.fr:1234"))),
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
GRPC_MDELEM_TE_TRAILERS,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
grpc_slice_intern(grpc_slice_from_static_string(
"grpc-c/3.0.0-dev (linux; chttp2; green)")))};
}
@@ -314,6 +303,7 @@ class RepresentativeClientInitialMetadata {
template <class Metadata>
static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
grpc_transport_stream_op_batch op;
@@ -330,34 +320,33 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
b.deadline = GRPC_MILLIS_INF_FUTURE;
- std::vector<grpc_mdelem> elems = Metadata::GetElems(f.exec_ctx());
+ std::vector<grpc_mdelem> elems = Metadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
f.FlushExecCtx();
- start = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
+ start = MakeClosure([&](grpc_error* error) {
if (!state.KeepRunning()) return;
s.Init(state);
reset_op();
op.on_complete = done.get();
op.send_initial_metadata = true;
op.payload->send_initial_metadata.send_initial_metadata = &b;
- s.Op(exec_ctx, &op);
+ s.Op(&op);
});
- done = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
+ done = MakeClosure([&](grpc_error* error) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(exec_ctx, &op);
- s.DestroyThen(exec_ctx, start.get());
+ s.Op(&op);
+ s.DestroyThen(start.get());
});
- GRPC_CLOSURE_SCHED(f.exec_ctx(), start.get(), GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(start.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
+ grpc_metadata_batch_destroy(&b);
track_counters.Finish(state);
}
BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy,
@@ -365,6 +354,7 @@ BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy,
static void BM_TransportEmptyOp(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
s.Init(state);
@@ -375,21 +365,19 @@ static void BM_TransportEmptyOp(benchmark::State& state) {
memset(&op, 0, sizeof(op));
op.payload = &op_payload;
};
- std::unique_ptr<Closure> c =
- MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (!state.KeepRunning()) return;
- reset_op();
- op.on_complete = c.get();
- s.Op(exec_ctx, &op);
- });
- GRPC_CLOSURE_SCHED(f.exec_ctx(), c.get(), GRPC_ERROR_NONE);
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) return;
+ reset_op();
+ op.on_complete = c.get();
+ s.Op(&op);
+ });
+ GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
reset_op();
op.cancel_stream = true;
op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(f.exec_ctx(), &op);
- s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx,
- grpc_error* error) {}));
+ s.Op(&op);
+ s.DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
track_counters.Finish(state);
}
@@ -399,6 +387,7 @@ std::vector<std::unique_ptr<gpr_event>> done_events;
static void BM_TransportStreamSend(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
auto s = std::unique_ptr<Stream>(new Stream(&f));
s->Init(state);
@@ -420,39 +409,37 @@ static void BM_TransportStreamSend(benchmark::State& state) {
grpc_metadata_batch_init(&b);
b.deadline = GRPC_MILLIS_INF_FUTURE;
std::vector<grpc_mdelem> elems =
- RepresentativeClientInitialMetadata::GetElems(f.exec_ctx());
+ RepresentativeClientInitialMetadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
gpr_event* bm_done = new gpr_event;
gpr_event_init(bm_done);
- std::unique_ptr<Closure> c =
- MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (!state.KeepRunning()) {
- gpr_event_set(bm_done, (void*)1);
- return;
- }
- // force outgoing window to be yuge
- s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
- f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
- grpc_slice_buffer_stream_init(&send_stream, &send_buffer, 0);
- reset_op();
- op.on_complete = c.get();
- op.send_message = true;
- op.payload->send_message.send_message = &send_stream.base;
- s->Op(exec_ctx, &op);
- });
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) {
+ gpr_event_set(bm_done, (void*)1);
+ return;
+ }
+ // force outgoing window to be yuge
+ s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
+ f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
+ grpc_slice_buffer_stream_init(&send_stream, &send_buffer, 0);
+ reset_op();
+ op.on_complete = c.get();
+ op.send_message = true;
+ op.payload->send_message.send_message = &send_stream.base;
+ s->Op(&op);
+ });
reset_op();
op.send_initial_metadata = true;
op.payload->send_initial_metadata.send_initial_metadata = &b;
op.on_complete = c.get();
- s->Op(f.exec_ctx(), &op);
+ s->Op(&op);
f.FlushExecCtx();
gpr_event_wait(bm_done, gpr_inf_future(GPR_CLOCK_REALTIME));
@@ -461,13 +448,12 @@ static void BM_TransportStreamSend(benchmark::State& state) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s->Op(f.exec_ctx(), &op);
- s->DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx,
- grpc_error* error) {}));
+ s->Op(&op);
+ s->DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
s.reset();
track_counters.Finish(state);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
+ grpc_metadata_batch_destroy(&b);
grpc_slice_buffer_destroy(&send_buffer);
}
BENCHMARK(BM_TransportStreamSend)->Range(0, 128 * 1024 * 1024);
@@ -531,6 +517,7 @@ static grpc_slice CreateIncomingDataSlice(size_t length, size_t frame_size) {
static void BM_TransportStreamRecv(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
s.Init(state);
@@ -551,16 +538,14 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
grpc_metadata_batch_init(&b_recv);
b.deadline = GRPC_MILLIS_INF_FUTURE;
std::vector<grpc_mdelem> elems =
- RepresentativeClientInitialMetadata::GetElems(f.exec_ctx());
+ RepresentativeClientInitialMetadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
- std::unique_ptr<Closure> do_nothing =
- MakeClosure([](grpc_exec_ctx* exec_ctx, grpc_error* error) {});
+ std::unique_ptr<Closure> do_nothing = MakeClosure([](grpc_error* error) {});
uint32_t received;
@@ -569,51 +554,49 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
std::unique_ptr<Closure> drain_continue;
grpc_slice recv_slice;
- std::unique_ptr<Closure> c =
- MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (!state.KeepRunning()) return;
- // force outgoing window to be yuge
- s.chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
- f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
- received = 0;
- reset_op();
- op.on_complete = do_nothing.get();
- op.recv_message = true;
- op.payload->recv_message.recv_message = &recv_stream;
- op.payload->recv_message.recv_message_ready = drain_start.get();
- s.Op(exec_ctx, &op);
- f.PushInput(grpc_slice_ref(incoming_data));
- });
-
- drain_start = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) return;
+ // force outgoing window to be yuge
+ s.chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
+ f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
+ received = 0;
+ reset_op();
+ op.on_complete = do_nothing.get();
+ op.recv_message = true;
+ op.payload->recv_message.recv_message = &recv_stream;
+ op.payload->recv_message.recv_message_ready = drain_start.get();
+ s.Op(&op);
+ f.PushInput(grpc_slice_ref(incoming_data));
+ });
+
+ drain_start = MakeClosure([&](grpc_error* error) {
if (recv_stream == nullptr) {
GPR_ASSERT(!state.KeepRunning());
return;
}
- GRPC_CLOSURE_RUN(exec_ctx, drain.get(), GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(drain.get(), GRPC_ERROR_NONE);
});
- drain = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
+ drain = MakeClosure([&](grpc_error* error) {
do {
if (received == recv_stream->length) {
- grpc_byte_stream_destroy(exec_ctx, recv_stream);
- GRPC_CLOSURE_SCHED(exec_ctx, c.get(), GRPC_ERROR_NONE);
+ grpc_byte_stream_destroy(recv_stream);
+ GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE);
return;
}
- } while (grpc_byte_stream_next(exec_ctx, recv_stream,
- recv_stream->length - received,
+ } while (grpc_byte_stream_next(recv_stream, recv_stream->length - received,
drain_continue.get()) &&
GRPC_ERROR_NONE ==
- grpc_byte_stream_pull(exec_ctx, recv_stream, &recv_slice) &&
+ grpc_byte_stream_pull(recv_stream, &recv_slice) &&
(received += GRPC_SLICE_LENGTH(recv_slice),
- grpc_slice_unref_internal(exec_ctx, recv_slice), true));
+ grpc_slice_unref_internal(recv_slice), true));
});
- drain_continue = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- grpc_byte_stream_pull(exec_ctx, recv_stream, &recv_slice);
+ drain_continue = MakeClosure([&](grpc_error* error) {
+ grpc_byte_stream_pull(recv_stream, &recv_slice);
received += GRPC_SLICE_LENGTH(recv_slice);
- grpc_slice_unref_internal(exec_ctx, recv_slice);
- GRPC_CLOSURE_RUN(exec_ctx, drain.get(), GRPC_ERROR_NONE);
+ grpc_slice_unref_internal(recv_slice);
+ GRPC_CLOSURE_RUN(drain.get(), GRPC_ERROR_NONE);
});
reset_op();
@@ -624,7 +607,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
op.payload->recv_initial_metadata.recv_initial_metadata_ready =
do_nothing.get();
op.on_complete = c.get();
- s.Op(f.exec_ctx(), &op);
+ s.Op(&op);
f.PushInput(SLICE_FROM_BUFFER(
"\x00\x00\x00\x04\x00\x00\x00\x00\x00"
// Generated using:
@@ -642,13 +625,12 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(f.exec_ctx(), &op);
- s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx,
- grpc_error* error) {}));
+ s.Op(&op);
+ s.DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
track_counters.Finish(state);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b_recv);
+ grpc_metadata_batch_destroy(&b);
+ grpc_metadata_batch_destroy(&b_recv);
grpc_slice_unref(incoming_data);
}
BENCHMARK(BM_TransportStreamRecv)->Range(0, 128 * 1024 * 1024);
diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc
index 2434d4e84e..f28093ae17 100644
--- a/test/cpp/microbenchmarks/bm_closure.cc
+++ b/test/cpp/microbenchmarks/bm_closure.cc
@@ -34,8 +34,7 @@ auto& force_library_initialization = Library::get();
static void BM_NoOpExecCtx(benchmark::State& state) {
TrackCounters track_counters;
while (state.KeepRunning()) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
}
track_counters.Finish(state);
}
@@ -43,16 +42,16 @@ BENCHMARK(BM_NoOpExecCtx);
static void BM_WellFlushed(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_WellFlushed);
-static void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void DoNothing(void* arg, grpc_error* error) {}
static void BM_ClosureInitAgainstExecCtx(benchmark::State& state) {
TrackCounters track_counters;
@@ -69,13 +68,13 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) {
TrackCounters track_counters;
grpc_combiner* combiner = grpc_combiner_create();
grpc_closure c;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
benchmark::DoNotOptimize(GRPC_CLOSURE_INIT(
&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner)));
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureInitAgainstCombiner);
@@ -84,41 +83,39 @@ static void BM_ClosureRunOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
grpc_closure c;
GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_RUN(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_RUN(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureRunOnExecCtx);
static void BM_ClosureCreateAndRun(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
GRPC_CLOSURE_RUN(
- &exec_ctx,
GRPC_CLOSURE_CREATE(DoNothing, nullptr, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureCreateAndRun);
static void BM_ClosureInitAndRun(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure c;
while (state.KeepRunning()) {
GRPC_CLOSURE_RUN(
- &exec_ctx,
GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureInitAndRun);
@@ -127,12 +124,12 @@ static void BM_ClosureSchedOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
grpc_closure c;
GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSchedOnExecCtx);
@@ -143,13 +140,13 @@ static void BM_ClosureSched2OnExecCtx(benchmark::State& state) {
grpc_closure c2;
GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnExecCtx);
@@ -162,14 +159,14 @@ static void BM_ClosureSched3OnExecCtx(benchmark::State& state) {
GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched3OnExecCtx);
@@ -179,13 +176,13 @@ static void BM_AcquireMutex(benchmark::State& state) {
// for comparison with the combiner stuff below
gpr_mu mu;
gpr_mu_init(&mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
gpr_mu_lock(&mu);
- DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_AcquireMutex);
@@ -195,16 +192,16 @@ static void BM_TryAcquireMutex(benchmark::State& state) {
// for comparison with the combiner stuff below
gpr_mu mu;
gpr_mu_init(&mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
if (gpr_mu_trylock(&mu)) {
- DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
} else {
abort();
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_TryAcquireMutex);
@@ -213,13 +210,13 @@ static void BM_AcquireSpinlock(benchmark::State& state) {
TrackCounters track_counters;
// for comparison with the combiner stuff below
gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
gpr_spinlock_lock(&mu);
- DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_AcquireSpinlock);
@@ -228,16 +225,16 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) {
TrackCounters track_counters;
// for comparison with the combiner stuff below
gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
if (gpr_spinlock_trylock(&mu)) {
- DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
} else {
abort();
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_TryAcquireSpinlock);
@@ -247,13 +244,13 @@ static void BM_ClosureSchedOnCombiner(benchmark::State& state) {
grpc_combiner* combiner = grpc_combiner_create();
grpc_closure c;
GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSchedOnCombiner);
@@ -265,14 +262,14 @@ static void BM_ClosureSched2OnCombiner(benchmark::State& state) {
grpc_closure c2;
GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnCombiner);
@@ -286,15 +283,15 @@ static void BM_ClosureSched3OnCombiner(benchmark::State& state) {
GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched3OnCombiner);
@@ -309,15 +306,15 @@ static void BM_ClosureSched2OnTwoCombiners(benchmark::State& state) {
grpc_combiner_scheduler(combiner1));
GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr,
grpc_combiner_scheduler(combiner2));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner1, "finished");
- GRPC_COMBINER_UNREF(&exec_ctx, combiner2, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner1, "finished");
+ GRPC_COMBINER_UNREF(combiner2, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnTwoCombiners);
@@ -338,17 +335,17 @@ static void BM_ClosureSched4OnTwoCombiners(benchmark::State& state) {
grpc_combiner_scheduler(combiner1));
GRPC_CLOSURE_INIT(&c4, DoNothing, nullptr,
grpc_combiner_scheduler(combiner2));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c4, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c4, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner1, "finished");
- GRPC_COMBINER_UNREF(&exec_ctx, combiner2, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner1, "finished");
+ GRPC_COMBINER_UNREF(combiner2, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched4OnTwoCombiners);
@@ -362,13 +359,11 @@ class Rescheduler {
GRPC_CLOSURE_INIT(&closure_, Step, this, scheduler);
}
- void ScheduleFirst(grpc_exec_ctx* exec_ctx) {
- GRPC_CLOSURE_SCHED(exec_ctx, &closure_, GRPC_ERROR_NONE);
- }
+ void ScheduleFirst() { GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); }
void ScheduleFirstAgainstDifferentScheduler(
- grpc_exec_ctx* exec_ctx, grpc_closure_scheduler* scheduler) {
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(Step, this, scheduler),
+ grpc_closure_scheduler* scheduler) {
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(Step, this, scheduler),
GRPC_ERROR_NONE);
}
@@ -376,47 +371,46 @@ class Rescheduler {
benchmark::State& state_;
grpc_closure closure_;
- static void Step(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ static void Step(void* arg, grpc_error* error) {
Rescheduler* self = static_cast<Rescheduler*>(arg);
if (self->state_.KeepRunning()) {
- GRPC_CLOSURE_SCHED(exec_ctx, &self->closure_, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&self->closure_, GRPC_ERROR_NONE);
}
}
};
static void BM_ClosureReschedOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
Rescheduler r(state, grpc_schedule_on_exec_ctx);
- r.ScheduleFirst(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirst();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnExecCtx);
static void BM_ClosureReschedOnCombiner(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
Rescheduler r(state, grpc_combiner_scheduler(combiner));
- r.ScheduleFirst(&exec_ctx);
- grpc_exec_ctx_flush(&exec_ctx);
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirst();
+ grpc_core::ExecCtx::Get()->Flush();
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnCombiner);
static void BM_ClosureReschedOnCombinerFinally(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
Rescheduler r(state, grpc_combiner_finally_scheduler(combiner));
- r.ScheduleFirstAgainstDifferentScheduler(&exec_ctx,
- grpc_combiner_scheduler(combiner));
- grpc_exec_ctx_flush(&exec_ctx);
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirstAgainstDifferentScheduler(grpc_combiner_scheduler(combiner));
+ grpc_core::ExecCtx::Get()->Flush();
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnCombinerFinally);
diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc
index f0dede7333..16f451d98f 100644
--- a/test/cpp/microbenchmarks/bm_cq.cc
+++ b/test/cpp/microbenchmarks/bm_cq.cc
@@ -66,7 +66,7 @@ static void BM_CreateDestroyCore(benchmark::State& state) {
}
BENCHMARK(BM_CreateDestroyCore);
-static void DoneWithCompletionOnStack(grpc_exec_ctx* exec_ctx, void* arg,
+static void DoneWithCompletionOnStack(void* arg,
grpc_cq_completion* completion) {}
class DummyTag final : public internal::CompletionQueueTag {
@@ -81,11 +81,11 @@ static void BM_Pass1Cpp(benchmark::State& state) {
while (state.KeepRunning()) {
grpc_cq_completion completion;
DummyTag dummy_tag;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(c_cq, &dummy_tag));
- grpc_cq_end_op(&exec_ctx, c_cq, &dummy_tag, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, nullptr, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_cq_end_op(c_cq, &dummy_tag, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
void* tag;
bool ok;
cq.Next(&tag, &ok);
@@ -101,11 +101,11 @@ static void BM_Pass1Core(benchmark::State& state) {
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
while (state.KeepRunning()) {
grpc_cq_completion completion;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(cq, nullptr));
- grpc_cq_end_op(&exec_ctx, cq, nullptr, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, nullptr, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_cq_end_op(cq, nullptr, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
grpc_completion_queue_next(cq, deadline, nullptr);
}
grpc_completion_queue_destroy(cq);
@@ -120,11 +120,11 @@ static void BM_Pluck1Core(benchmark::State& state) {
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
while (state.KeepRunning()) {
grpc_cq_completion completion;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(cq, nullptr));
- grpc_cq_end_op(&exec_ctx, cq, nullptr, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, nullptr, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_cq_end_op(cq, nullptr, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
grpc_completion_queue_pluck(cq, nullptr, deadline, nullptr);
}
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 7ccebb55ee..874c834931 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -43,9 +43,8 @@ static grpc_completion_queue* g_cq;
static grpc_event_engine_vtable g_vtable;
static const grpc_event_engine_vtable* g_old_vtable;
-static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
- grpc_closure* closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+static void pollset_shutdown(grpc_pollset* ps, grpc_closure* closure) {
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
}
static void pollset_init(grpc_pollset* ps, gpr_mu** mu) {
@@ -53,25 +52,20 @@ static void pollset_init(grpc_pollset* ps, gpr_mu** mu) {
*mu = &ps->mu;
}
-static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* ps) {
- gpr_mu_destroy(&ps->mu);
-}
+static void pollset_destroy(grpc_pollset* ps) { gpr_mu_destroy(&ps->mu); }
-static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
- grpc_pollset_worker* worker) {
+static grpc_error* pollset_kick(grpc_pollset* p, grpc_pollset_worker* worker) {
return GRPC_ERROR_NONE;
}
/* Callback when the tag is dequeued from the completion queue. Does nothing */
-static void cq_done_cb(grpc_exec_ctx* exec_ctx, void* done_arg,
- grpc_cq_completion* cq_completion) {
+static void cq_done_cb(void* done_arg, grpc_cq_completion* cq_completion) {
gpr_free(cq_completion);
}
/* Queues a completion tag if deadline is > 0.
* Does nothing if deadline is 0 (i.e gpr_time_0(GPR_CLOCK_MONOTONIC)) */
-static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
- grpc_pollset_worker** worker,
+static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker,
grpc_millis deadline) {
if (deadline == 0) {
gpr_log(GPR_DEBUG, "no-op");
@@ -80,9 +74,9 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
gpr_mu_unlock(&ps->mu);
GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag));
- grpc_cq_end_op(exec_ctx, g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
+ grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::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 02a93e90cc..0ee491a271 100644
--- a/test/cpp/microbenchmarks/bm_error.cc
+++ b/test/cpp/microbenchmarks/bm_error.cc
@@ -246,14 +246,14 @@ template <class Fixture>
static void BM_ErrorGetStatus(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
grpc_status_code status;
grpc_slice slice;
- grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
- &status, &slice, nullptr);
+ grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice,
+ nullptr);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
@@ -261,13 +261,13 @@ template <class Fixture>
static void BM_ErrorGetStatusCode(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
grpc_status_code status;
- grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
- &status, nullptr, nullptr);
+ grpc_error_get_status(fixture.error(), fixture.deadline(), &status, nullptr,
+ nullptr);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
@@ -275,13 +275,13 @@ template <class Fixture>
static void BM_ErrorHttpError(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
grpc_http2_error_code error;
- grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
- nullptr, nullptr, &error);
+ grpc_error_get_status(fixture.error(), fixture.deadline(), nullptr, nullptr,
+ &error);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
index bb974fad50..23ca750307 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
@@ -177,13 +177,13 @@ class TrickledCHTTP2 : public EndpointPairFixture {
}
void Step(bool update_stats) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
inc_time();
size_t client_backlog =
- grpc_trickle_endpoint_trickle(&exec_ctx, endpoint_pair_.client);
+ grpc_trickle_endpoint_trickle(endpoint_pair_.client);
size_t server_backlog =
- grpc_trickle_endpoint_trickle(&exec_ctx, endpoint_pair_.server);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_trickle_endpoint_trickle(endpoint_pair_.server);
+
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 73bce08466..62c9a2e335 100644
--- a/test/cpp/microbenchmarks/bm_metadata.cc
+++ b/test/cpp/microbenchmarks/bm_metadata.cc
@@ -90,11 +90,11 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_from_static_string("key");
gpr_slice v = grpc_slice_from_static_string("value");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataFromNonInternedSlices);
@@ -103,11 +103,11 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -119,13 +119,13 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex(
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem seed = grpc_mdelem_create(&exec_ctx, k, v, nullptr);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_mdelem seed = grpc_mdelem_create(k, v, nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- GRPC_MDELEM_UNREF(&exec_ctx, seed);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(seed);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -136,11 +136,11 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_from_static_string("value");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -152,14 +152,12 @@ static void BM_MetadataFromNonInternedSlicesWithBackingStore(
gpr_slice k = grpc_slice_from_static_string("key");
gpr_slice v = grpc_slice_from_static_string("value");
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataFromNonInternedSlicesWithBackingStore);
@@ -170,14 +168,12 @@ static void BM_MetadataFromInternedSlicesWithBackingStore(
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -190,14 +186,12 @@ static void BM_MetadataFromInternedKeyWithBackingStore(
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_from_static_string("value");
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -207,11 +201,11 @@ static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = GRPC_MDSTR_STATUS;
gpr_slice v = GRPC_MDSTR_200;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -222,11 +216,11 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed(
TrackCounters track_counters;
gpr_slice k = GRPC_MDSTR_STATUS;
gpr_slice v = GRPC_MDSTR_GZIP;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -235,16 +229,15 @@ BENCHMARK(BM_MetadataFromStaticMetadataStringsNotIndexed);
static void BM_MetadataRefUnrefExternal(benchmark::State& state) {
TrackCounters track_counters;
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, grpc_slice_from_static_string("a"),
- grpc_slice_from_static_string("b"),
- reinterpret_cast<grpc_mdelem_data*>(backing_store));
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_mdelem el = grpc_mdelem_create(
+ grpc_slice_from_static_string("a"), grpc_slice_from_static_string("b"),
+ reinterpret_cast<grpc_mdelem_data*>(backing_store));
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefExternal);
@@ -252,47 +245,47 @@ BENCHMARK(BM_MetadataRefUnrefExternal);
static void BM_MetadataRefUnrefInterned(benchmark::State& state) {
TrackCounters track_counters;
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
grpc_mdelem el = grpc_mdelem_create(
- &exec_ctx, k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store));
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store));
grpc_slice_unref(k);
grpc_slice_unref(v);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefInterned);
static void BM_MetadataRefUnrefAllocated(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, grpc_slice_from_static_string("a"),
+ grpc_mdelem_create(grpc_slice_from_static_string("a"),
grpc_slice_from_static_string("b"), nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefAllocated);
static void BM_MetadataRefUnrefStatic(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr);
+ grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefStatic);
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc
index 4da79693f1..ec0bf4e4b9 100644
--- a/test/cpp/microbenchmarks/bm_pollset.cc
+++ b/test/cpp/microbenchmarks/bm_pollset.cc
@@ -41,8 +41,8 @@
auto& force_library_initialization = Library::get();
-static void shutdown_ps(grpc_exec_ctx* exec_ctx, void* ps, grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(ps));
+static void shutdown_ps(void* ps, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(ps));
}
static void BM_CreateDestroyPollset(benchmark::State& state) {
@@ -50,7 +50,7 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
size_t ps_sz = grpc_pollset_size();
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_malloc(ps_sz));
gpr_mu* mu;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
@@ -58,11 +58,11 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
memset(ps, 0, ps_sz);
grpc_pollset_init(ps, &mu);
gpr_mu_lock(mu);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -114,17 +114,17 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_mu_lock(mu);
while (state.KeepRunning()) {
- GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, nullptr, 0));
+ GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, 0));
}
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -136,24 +136,23 @@ static void BM_PollAddFd(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_wakeup_fd wakeup_fd;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd)));
grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx");
while (state.KeepRunning()) {
- grpc_pollset_add_fd(&exec_ctx, ps, fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(ps, fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_fd_orphan(&exec_ctx, fd, nullptr, nullptr, false /* already_closed */,
- "xxx");
+ grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, "xxx");
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
gpr_mu_lock(mu);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -170,7 +169,7 @@ Closure* MakeClosure(F f, grpc_closure_scheduler* scheduler) {
C(F f, grpc_closure_scheduler* scheduler) : f_(f) {
GRPC_CLOSURE_INIT(this, C::cbfn, this, scheduler);
}
- static void cbfn(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ static void cbfn(void* arg, grpc_error* error) {
C* p = static_cast<C*>(arg);
p->f_();
}
@@ -219,11 +218,11 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_wakeup_fd wakeup_fd;
GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd));
grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read");
- grpc_pollset_add_fd(&exec_ctx, ps, wakeup);
+ grpc_pollset_add_fd(ps, wakeup);
bool done = false;
Closure* continue_closure = MakeClosure(
[&]() {
@@ -233,25 +232,23 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
return;
}
GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd));
- grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
+ grpc_fd_notify_on_read(wakeup, continue_closure);
},
grpc_schedule_on_exec_ctx);
GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd));
- grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
+ grpc_fd_notify_on_read(wakeup, continue_closure);
gpr_mu_lock(mu);
while (!done) {
- GRPC_ERROR_UNREF(
- grpc_pollset_work(&exec_ctx, ps, nullptr, GRPC_MILLIS_INF_FUTURE));
+ GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, GRPC_MILLIS_INF_FUTURE));
}
- grpc_fd_orphan(&exec_ctx, wakeup, nullptr, nullptr,
- false /* already_closed */, "done");
+ grpc_fd_orphan(wakeup, nullptr, nullptr, false /* already_closed */, "done");
wakeup_fd.read_fd = 0;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
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 7f1aa48b56..1520282009 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -166,7 +166,7 @@ class EndpointPairFixture : public BaseFixture {
fixture_configuration.ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* add server endpoint to server_
* */
@@ -174,20 +174,19 @@ class EndpointPairFixture : public BaseFixture {
const grpc_channel_args* server_args =
grpc_server_get_channel_args(server_->c_server());
server_transport_ = grpc_create_chttp2_transport(
- &exec_ctx, server_args, endpoints.server, 0 /* is_client */);
+ server_args, endpoints.server, 0 /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server_->c_server(), &pollsets, &num_pollsets);
for (size_t i = 0; i < num_pollsets; i++) {
- grpc_endpoint_add_to_pollset(&exec_ctx, endpoints.server, pollsets[i]);
+ grpc_endpoint_add_to_pollset(endpoints.server, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server_->c_server(),
- server_transport_, nullptr, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, server_transport_,
- nullptr);
+ grpc_server_setup_transport(server_->c_server(), server_transport_,
+ nullptr, server_args);
+ grpc_chttp2_transport_start_reading(server_transport_, nullptr);
}
/* create channel */
@@ -198,18 +197,14 @@ class EndpointPairFixture : public BaseFixture {
grpc_channel_args c_args = args.c_channel_args();
client_transport_ =
- grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1);
+ grpc_create_chttp2_transport(&c_args, endpoints.client, 1);
GPR_ASSERT(client_transport_);
- grpc_channel* channel =
- grpc_channel_create(&exec_ctx, "target", &c_args,
- GRPC_CLIENT_DIRECT_CHANNEL, client_transport_);
- grpc_chttp2_transport_start_reading(&exec_ctx, client_transport_,
- nullptr);
+ grpc_channel* channel = grpc_channel_create(
+ "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_);
+ grpc_chttp2_transport_start_reading(client_transport_, nullptr);
channel_ = CreateChannelInternal("", channel);
}
-
- grpc_exec_ctx_finish(&exec_ctx);
}
virtual ~EndpointPairFixture() {
diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc
index 6f1f0c44b9..3bd1df9429 100644
--- a/test/cpp/naming/resolver_component_test.cc
+++ b/test/cpp/naming/resolver_component_test.cc
@@ -149,33 +149,33 @@ struct ArgsStruct {
std::string expected_lb_policy;
};
-void ArgsInit(grpc_exec_ctx* exec_ctx, ArgsStruct* args) {
+void ArgsInit(ArgsStruct* args) {
gpr_event_init(&args->ev);
args->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(args->pollset, &args->mu);
args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
args->lock = grpc_combiner_create();
gpr_atm_rel_store(&args->done_atm, 0);
args->channel_args = nullptr;
}
-void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+void DoNothing(void* arg, grpc_error* error) {}
-void ArgsFinish(grpc_exec_ctx* exec_ctx, ArgsStruct* args) {
+void ArgsFinish(ArgsStruct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, TestDeadline()));
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
grpc_closure DoNothing_cb;
GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, nullptr,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &DoNothing_cb);
+ grpc_pollset_shutdown(args->pollset, &DoNothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_channel_args_destroy(exec_ctx, args->channel_args);
- grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
+ grpc_channel_args_destroy(args->channel_args);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
- GRPC_COMBINER_UNREF(exec_ctx, args->lock, NULL);
+ GRPC_COMBINER_UNREF(args->lock, nullptr);
}
gpr_timespec NSecondDeadline(int seconds) {
@@ -196,14 +196,13 @@ void PollPollsetUntilRequestDone(ArgsStruct* args) {
time_left.tv_sec, time_left.tv_nsec);
GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0);
grpc_pollset_worker* worker = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
+ grpc_pollset_work(args->pollset, &worker,
grpc_timespec_to_millis_round_up(
NSecondDeadline(1))));
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
gpr_event_set(&args->ev, (void*)1);
}
@@ -235,8 +234,7 @@ void CheckLBPolicyResultLocked(grpc_channel_args* channel_args,
}
}
-void CheckResolverResultLocked(grpc_exec_ctx* exec_ctx, void* argsp,
- grpc_error* err) {
+void CheckResolverResultLocked(void* argsp, grpc_error* err) {
ArgsStruct* args = (ArgsStruct*)argsp;
grpc_channel_args* channel_args = args->channel_args;
const grpc_arg* channel_arg =
@@ -272,15 +270,14 @@ void CheckResolverResultLocked(grpc_exec_ctx* exec_ctx, void* argsp,
}
gpr_atm_rel_store(&args->done_atm, 1);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
ArgsStruct args;
- ArgsInit(&exec_ctx, &args);
+ ArgsInit(&args);
args.expected_addrs = ParseExpectedAddrs(FLAGS_expected_addrs);
args.expected_service_config_string = FLAGS_expected_chosen_service_config;
args.expected_lb_policy = FLAGS_expected_lb_policy;
@@ -290,19 +287,18 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
FLAGS_local_dns_server_address.c_str(),
FLAGS_target_name.c_str()));
// create resolver and resolve
- grpc_resolver* resolver = grpc_resolver_create(&exec_ctx, whole_uri, nullptr,
- args.pollset_set, args.lock);
+ grpc_resolver* resolver =
+ grpc_resolver_create(whole_uri, nullptr, args.pollset_set, args.lock);
gpr_free(whole_uri);
grpc_closure on_resolver_result_changed;
GRPC_CLOSURE_INIT(&on_resolver_result_changed, CheckResolverResultLocked,
(void*)&args, grpc_combiner_scheduler(args.lock));
- grpc_resolver_next_locked(&exec_ctx, resolver, &args.channel_args,
+ grpc_resolver_next_locked(resolver, &args.channel_args,
&on_resolver_result_changed);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
PollPollsetUntilRequestDone(&args);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, NULL);
- ArgsFinish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_RESOLVER_UNREF(resolver, nullptr);
+ ArgsFinish(&args);
}
} // namespace
diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc
index 23fff2ea8b..c5d29469b2 100644
--- a/test/cpp/performance/writes_per_rpc_test.cc
+++ b/test/cpp/performance/writes_per_rpc_test.cc
@@ -82,26 +82,26 @@ class EndpointPairFixture {
ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* add server endpoint to server_ */
{
const grpc_channel_args* server_args =
grpc_server_get_channel_args(server_->c_server());
grpc_transport* transport = grpc_create_chttp2_transport(
- &exec_ctx, server_args, endpoints.server, 0 /* is_client */);
+ server_args, endpoints.server, 0 /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server_->c_server(), &pollsets, &num_pollsets);
for (size_t i = 0; i < num_pollsets; i++) {
- grpc_endpoint_add_to_pollset(&exec_ctx, endpoints.server, pollsets[i]);
+ grpc_endpoint_add_to_pollset(endpoints.server, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server_->c_server(), transport,
- nullptr, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
+ grpc_server_setup_transport(server_->c_server(), transport, nullptr,
+ server_args);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
/* create channel */
@@ -112,16 +112,14 @@ class EndpointPairFixture {
grpc_channel_args c_args = args.c_channel_args();
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1);
+ grpc_create_chttp2_transport(&c_args, endpoints.client, 1);
GPR_ASSERT(transport);
grpc_channel* channel = grpc_channel_create(
- &exec_ctx, "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
+ "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
channel_ = CreateChannelInternal("", channel);
}
-
- grpc_exec_ctx_finish(&exec_ctx);
}
virtual ~EndpointPairFixture() {