diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-12-06 09:47:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 09:47:54 -0800 |
commit | 8cf1470a51ea276ca84825e7495d4ee24743540d (patch) | |
tree | 72385cc865094115bc08cb813201d48cb09840bb /test/core/iomgr/resource_quota_test.cc | |
parent | 1d4e99508409be052bd129ba507bae1fbe7eb7fa (diff) |
Revert "Revert "All instances of exec_ctx being passed around in src/core removed""
Diffstat (limited to 'test/core/iomgr/resource_quota_test.cc')
-rw-r--r-- | test/core/iomgr/resource_quota_test.cc | 354 |
1 files changed, 158 insertions, 196 deletions
diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc index 6851702e67..ae26f72701 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 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 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 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 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr1, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr2, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr1, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_alloc(usr2, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_free(usr1, 1024); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr1, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr2, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 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))); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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))); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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))); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&ev)); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, NULL); } { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_core::ExecCtx 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 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 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))); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&allocated)); + grpc_core::ExecCtx::Get()->Flush(); + 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 exec_ctx; + grpc_resource_user_unref(usr); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_free(usr, 1024); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&allocated)); + grpc_core::ExecCtx::Get()->Flush(); 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 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))); + grpc_core::ExecCtx::Get()->Flush(); 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 exec_ctx; + grpc_resource_user_alloc(usr, 1024, set_event(&allocated)); + grpc_core::ExecCtx::Get()->Flush(); + 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 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 exec_ctx; + grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer); + grpc_core::ExecCtx::Get()->Flush(); 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 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 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 exec_ctx; + grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer); + grpc_core::ExecCtx::Get()->Flush(); 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 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 exec_ctx; + grpc_slice_buffer_destroy_internal(&buffer); } } |