aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Masood Malekghassemi <atash@google.com>2017-01-05 15:07:26 -0800
committerGravatar Masood Malekghassemi <atash@google.com>2017-01-05 18:43:59 -0800
commitb5b4372670190e680520236c5f3c7d79058f5931 (patch)
tree16bbc0853d2bcdf5c03077cb5592ee7005bb395f /test/core
parent3a35f7ecbcef2f762a86a5874ecfc680bb870aaa (diff)
Use `grpc_closure`s in `grpc_timer`s
Diffstat (limited to 'test/core')
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.c18
-rw-r--r--test/core/iomgr/timer_list_test.c43
2 files changed, 38 insertions, 23 deletions
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c
index 6c7cbadea3..200a51858a 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.c
+++ b/test/core/end2end/fuzzers/api_fuzzer.c
@@ -369,10 +369,11 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
r->addr = gpr_strdup(addr);
r->on_done = on_done;
r->addrs = addresses;
- grpc_timer_init(exec_ctx, &r->timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_seconds(1, GPR_TIMESPAN)),
- finish_resolve, r, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(
+ exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_seconds(1, GPR_TIMESPAN)),
+ grpc_closure_create(finish_resolve, r, grpc_schedule_on_exec_ctx),
+ gpr_now(GPR_CLOCK_MONOTONIC));
}
////////////////////////////////////////////////////////////////////////////////
@@ -430,10 +431,11 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
fc->closure = closure;
fc->ep = ep;
fc->deadline = deadline;
- grpc_timer_init(exec_ctx, &fc->timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_millis(1, GPR_TIMESPAN)),
- do_connect, fc, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(
+ exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_millis(1, GPR_TIMESPAN)),
+ grpc_closure_create(do_connect, fc, grpc_schedule_on_exec_ctx),
+ gpr_now(GPR_CLOCK_MONOTONIC));
}
static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx,
diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c
index be8988ab75..8d7ac3fdaa 100644
--- a/test/core/iomgr/timer_list_test.c
+++ b/test/core/iomgr/timer_list_test.c
@@ -57,17 +57,20 @@ static void add_test(void) {
/* 10 ms timers. will expire in the current epoch */
for (i = 0; i < 10; i++) {
- grpc_timer_init(&exec_ctx, &timers[i],
- gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)),
- cb, (void *)(intptr_t)i, start);
+ grpc_timer_init(
+ &exec_ctx, &timers[i],
+ gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)),
+ grpc_closure_create(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx),
+ start);
}
/* 1010 ms timers. will expire in the next epoch */
for (i = 10; i < 20; i++) {
grpc_timer_init(
&exec_ctx, &timers[i],
- gpr_time_add(start, gpr_time_from_millis(1010, GPR_TIMESPAN)), cb,
- (void *)(intptr_t)i, start);
+ gpr_time_add(start, gpr_time_from_millis(1010, GPR_TIMESPAN)),
+ grpc_closure_create(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx),
+ start);
}
/* collect timers. Only the first batch should be ready. */
@@ -125,16 +128,26 @@ void destruction_test(void) {
grpc_timer_list_init(gpr_time_0(GPR_CLOCK_REALTIME));
memset(cb_called, 0, sizeof(cb_called));
- grpc_timer_init(&exec_ctx, &timers[0], tfm(100), cb, (void *)(intptr_t)0,
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(&exec_ctx, &timers[1], tfm(3), cb, (void *)(intptr_t)1,
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(&exec_ctx, &timers[2], tfm(100), cb, (void *)(intptr_t)2,
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(&exec_ctx, &timers[3], tfm(3), cb, (void *)(intptr_t)3,
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(&exec_ctx, &timers[4], tfm(1), cb, (void *)(intptr_t)4,
- gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[0], tfm(100),
+ grpc_closure_create(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[1], tfm(3),
+ grpc_closure_create(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[2], tfm(100),
+ grpc_closure_create(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[3], tfm(3),
+ grpc_closure_create(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[4], tfm(1),
+ grpc_closure_create(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
GPR_ASSERT(1 == grpc_timer_check(&exec_ctx, tfm(2), NULL));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(1 == cb_called[4][1]);