From db1e643c60d9b521c421f3f528e7946dd37cacbf Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Fri, 23 Oct 1998 23:00:40 +0000 Subject: [PATCH] isc_interval_t conversion --- bin/tests/task_test.c | 11 ++++++----- bin/tests/timer_test.c | 34 ++++++++++++++-------------------- lib/isc/include/isc/timer.h | 4 ++-- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/bin/tests/task_test.c b/bin/tests/task_test.c index 18b767d060..c968cf3a07 100644 --- a/bin/tests/task_test.c +++ b/bin/tests/task_test.c @@ -54,7 +54,8 @@ main(int argc, char *argv[]) { unsigned int workers; isc_timermgr_t timgr; isc_timer_t ti1, ti2; - struct isc_time absolute, interval; + struct isc_time absolute; + struct isc_interval interval; if (argc > 1) workers = atoi(argv[1]); @@ -79,14 +80,14 @@ main(int argc, char *argv[]) { timgr = NULL; INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS); ti1 = NULL; - absolute.seconds = 0; - absolute.nanoseconds = 0; - interval.seconds = 1; - interval.nanoseconds = 0; + isc_time_settoepoch(&absolute); + isc_interval_set(&interval, 1, 0); INSIST(isc_timer_create(timgr, isc_timertype_ticker, &absolute, &interval, t1, my_tick, "foo", &ti1) == ISC_R_SUCCESS); ti2 = NULL; + isc_time_settoepoch(&absolute); + isc_interval_set(&interval, 1, 0); INSIST(isc_timer_create(timgr, isc_timertype_ticker, &absolute, &interval, t2, my_tick, "bar", &ti2) == ISC_R_SUCCESS); diff --git a/bin/tests/timer_test.c b/bin/tests/timer_test.c index 41873760fc..c9fa67a70c 100644 --- a/bin/tests/timer_test.c +++ b/bin/tests/timer_test.c @@ -39,14 +39,13 @@ tick(isc_task_t task, isc_event_t event) isc_timer_touch(ti3); if (tick_count == 7) { - struct isc_time expires, interval, now; + struct isc_time expires, now; + struct isc_interval interval; (void)isc_time_get(&now); - expires.seconds = 5; - expires.nanoseconds = 0; - isc_time_add(&now, &expires, &expires); - interval.seconds = 4; - interval.nanoseconds = 0; + isc_interval_set(&interval, 5, 0); + isc_time_add(&now, &interval, &expires); + isc_interval_set(&interval, 4, 0); printf("*** resetting ti3 ***\n"); INSIST(isc_timer_reset(ti3, isc_timertype_once, &expires, &interval, ISC_TRUE) @@ -83,7 +82,8 @@ main(int argc, char *argv[]) { isc_taskmgr_t manager = NULL; isc_timermgr_t timgr = NULL; unsigned int workers; - struct isc_time expires, interval, now; + struct isc_time expires, now; + struct isc_interval interval; if (argc > 1) workers = atoi(argv[1]); @@ -108,24 +108,18 @@ main(int argc, char *argv[]) { (void)isc_time_get(&now); - expires.seconds = 0; - expires.nanoseconds = 0; - interval.seconds = 2; - interval.nanoseconds = 0; + isc_time_settoepoch(&expires); + isc_interval_set(&interval, 2, 0); INSIST(isc_timer_create(timgr, isc_timertype_once, &expires, &interval, t2, timeout, "2", &ti2) == ISC_R_SUCCESS); - expires.seconds = 0; - expires.nanoseconds = 0; - interval.seconds = 1; - interval.nanoseconds = 0; + isc_time_settoepoch(&expires); + isc_interval_set(&interval, 1, 0); INSIST(isc_timer_create(timgr, isc_timertype_ticker, &expires, &interval, t1, tick, "1", &ti1) == ISC_R_SUCCESS); - expires.seconds = 10; - expires.nanoseconds = 0; - isc_time_add(&now, &expires, &expires); - interval.seconds = 2; - interval.nanoseconds = 0; + isc_interval_set(&interval, 10, 0); + isc_time_add(&now, &interval, &expires); + isc_interval_set(&interval, 2, 0); INSIST(isc_timer_create(timgr, isc_timertype_once, &expires, &interval, t3, timeout, "3", &ti3) == ISC_R_SUCCESS); diff --git a/lib/isc/include/isc/timer.h b/lib/isc/include/isc/timer.h index 3e807f44b8..17621db913 100644 --- a/lib/isc/include/isc/timer.h +++ b/lib/isc/include/isc/timer.h @@ -92,7 +92,7 @@ isc_result_t isc_timer_create(isc_timermgr_t manager, isc_timertype_t type, isc_time_t expires, - isc_time_t interval, + isc_interval_t interval, isc_task_t task, isc_taskaction_t action, void *arg, @@ -147,7 +147,7 @@ isc_result_t isc_timer_reset(isc_timer_t timer, isc_timertype_t type, isc_time_t expires, - isc_time_t interval, + isc_interval_t interval, isc_boolean_t purge); /* * Change the timer's type, expires, and interval values to the given