more renaming

This commit is contained in:
Bob Halley
1998-10-21 01:57:35 +00:00
parent 35815e1e2a
commit 5f74ac33a0
6 changed files with 127 additions and 122 deletions

View File

@@ -22,7 +22,7 @@ my_callback(task_t task, task_event_t event)
j = 0; j = 0;
for (i = 0; i < 1000000; i++) for (i = 0; i < 1000000; i++)
j += 100; j += 100;
printf("task %s: %d\n", name, j); printf("task %s (%p): %d\n", name, task, j);
return (ISC_FALSE); return (ISC_FALSE);
} }
@@ -31,7 +31,7 @@ static isc_boolean_t
my_shutdown(task_t task, task_event_t event) { my_shutdown(task_t task, task_event_t event) {
char *name = event->arg; char *name = event->arg;
printf("shutdown %s\n", name); printf("shutdown %s (%p)\n", name, task);
return (ISC_TRUE); return (ISC_TRUE);
} }
@@ -51,8 +51,8 @@ main(int argc, char *argv[]) {
task_t t3 = NULL, t4 = NULL; task_t t3 = NULL, t4 = NULL;
task_event_t event; task_event_t event;
unsigned int workers; unsigned int workers;
timer_manager_t timgr; isc_timermgr_t timgr;
timer_t ti1, ti2; isc_timer_t ti1, ti2;
os_time_t absolute, interval; os_time_t absolute, interval;
if (argc > 1) if (argc > 1)
@@ -71,17 +71,19 @@ main(int argc, char *argv[]) {
INSIST(task_create(manager, my_shutdown, "4", 0, &t4)); INSIST(task_create(manager, my_shutdown, "4", 0, &t4));
timgr = NULL; timgr = NULL;
INSIST(timer_manager_create(mctx, &timgr) == ISC_R_SUCCESS); INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
ti1 = NULL; ti1 = NULL;
absolute.seconds = 0; absolute.seconds = 0;
absolute.nanoseconds = 0; absolute.nanoseconds = 0;
interval.seconds = 1; interval.seconds = 1;
interval.nanoseconds = 0; interval.nanoseconds = 0;
INSIST(timer_create(timgr, timer_type_ticker, absolute, interval, INSIST(isc_timer_create(timgr, isc_timertype_ticker,
t1, my_tick, "foo", &ti1) == ISC_R_SUCCESS); absolute, interval,
t1, my_tick, "foo", &ti1) == ISC_R_SUCCESS);
ti2 = NULL; ti2 = NULL;
INSIST(timer_create(timgr, timer_type_ticker, absolute, interval, INSIST(isc_timer_create(timgr, isc_timertype_ticker,
t2, my_tick, "bar", &ti2) == ISC_R_SUCCESS); absolute, interval,
t2, my_tick, "bar", &ti2) == ISC_R_SUCCESS);
printf("task 1 = %p\n", t1); printf("task 1 = %p\n", t1);
printf("task 2 = %p\n", t2); printf("task 2 = %p\n", t2);
@@ -141,9 +143,9 @@ main(int argc, char *argv[]) {
sleep(10); sleep(10);
printf("destroy\n"); printf("destroy\n");
timer_detach(&ti1); isc_timer_detach(&ti1);
timer_detach(&ti2); isc_timer_detach(&ti2);
timer_manager_destroy(&timgr); isc_timermgr_destroy(&timgr);
task_manager_destroy(&manager); task_manager_destroy(&manager);
printf("destroyed\n"); printf("destroyed\n");

View File

@@ -13,14 +13,14 @@
mem_context_t mctx = NULL; mem_context_t mctx = NULL;
task_t t1, t2, t3; task_t t1, t2, t3;
timer_t ti1, ti2, ti3; isc_timer_t ti1, ti2, ti3;
int tick_count = 0; int tick_count = 0;
static isc_boolean_t static isc_boolean_t
shutdown_task(task_t task, task_event_t event) { shutdown_task(task_t task, task_event_t event) {
char *name = event->arg; char *name = event->arg;
printf("shutdown %s\n", name); printf("task %p shutdown %s\n", task, name);
return (ISC_TRUE); return (ISC_TRUE);
} }
@@ -29,13 +29,13 @@ tick(task_t task, task_event_t event)
{ {
char *name = event->arg; char *name = event->arg;
INSIST(event->type == TIMER_EVENT_TICK); INSIST(event->type == ISC_TIMEREVENT_TICK);
printf("task %s (%p) tick\n", name, task); printf("task %s (%p) tick\n", name, task);
tick_count++; tick_count++;
if (tick_count % 3 == 0) if (tick_count % 3 == 0)
timer_touch(ti3); isc_timer_touch(ti3);
if (tick_count == 7) { if (tick_count == 7) {
os_time_t expires, interval, now; os_time_t expires, interval, now;
@@ -47,8 +47,8 @@ tick(task_t task, task_event_t event)
interval.seconds = 4; interval.seconds = 4;
interval.nanoseconds = 0; interval.nanoseconds = 0;
printf("*** resetting ti3 ***\n"); printf("*** resetting ti3 ***\n");
INSIST(timer_reset(ti3, timer_type_once, expires, interval, INSIST(isc_timer_reset(ti3, isc_timertype_once, expires,
ISC_TRUE) interval, ISC_TRUE)
== ISC_R_SUCCESS); == ISC_R_SUCCESS);
} }
@@ -61,10 +61,10 @@ timeout(task_t task, task_event_t event)
char *name = event->arg; char *name = event->arg;
char *type; char *type;
INSIST(event->type == TIMER_EVENT_IDLE || INSIST(event->type == ISC_TIMEREVENT_IDLE ||
event->type == TIMER_EVENT_LIFE); event->type == ISC_TIMEREVENT_LIFE);
if (event->type == TIMER_EVENT_IDLE) if (event->type == ISC_TIMEREVENT_IDLE)
type = "idle"; type = "idle";
else else
type = "life"; type = "life";
@@ -80,7 +80,7 @@ timeout(task_t task, task_event_t event)
void void
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
task_manager_t manager = NULL; task_manager_t manager = NULL;
timer_manager_t timgr = NULL; isc_timermgr_t timgr = NULL;
unsigned int workers; unsigned int workers;
os_time_t expires, interval, now; os_time_t expires, interval, now;
@@ -95,7 +95,7 @@ main(int argc, char *argv[]) {
INSIST(task_create(manager, shutdown_task, "1", 0, &t1)); INSIST(task_create(manager, shutdown_task, "1", 0, &t1));
INSIST(task_create(manager, shutdown_task, "2", 0, &t2)); INSIST(task_create(manager, shutdown_task, "2", 0, &t2));
INSIST(task_create(manager, shutdown_task, "3", 0, &t3)); INSIST(task_create(manager, shutdown_task, "3", 0, &t3));
INSIST(timer_manager_create(mctx, &timgr) == ISC_R_SUCCESS); INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
printf("task 1: %p\n", t1); printf("task 1: %p\n", t1);
printf("task 2: %p\n", t2); printf("task 2: %p\n", t2);
@@ -107,21 +107,21 @@ main(int argc, char *argv[]) {
expires.nanoseconds = 0; expires.nanoseconds = 0;
interval.seconds = 2; interval.seconds = 2;
interval.nanoseconds = 0; interval.nanoseconds = 0;
INSIST(timer_create(timgr, timer_type_once, expires, interval, INSIST(isc_timer_create(timgr, isc_timertype_once, expires, interval,
t2, timeout, "2", &ti2) == ISC_R_SUCCESS); t2, timeout, "2", &ti2) == ISC_R_SUCCESS);
expires.seconds = 0; expires.seconds = 0;
expires.nanoseconds = 0; expires.nanoseconds = 0;
interval.seconds = 1; interval.seconds = 1;
interval.nanoseconds = 0; interval.nanoseconds = 0;
INSIST(timer_create(timgr, timer_type_ticker, expires, interval, INSIST(isc_timer_create(timgr, isc_timertype_ticker, expires, interval,
t1, tick, "1", &ti1) == ISC_R_SUCCESS); t1, tick, "1", &ti1) == ISC_R_SUCCESS);
expires.seconds = 10; expires.seconds = 10;
expires.nanoseconds = 0; expires.nanoseconds = 0;
os_time_add(&now, &expires, &expires); os_time_add(&now, &expires, &expires);
interval.seconds = 2; interval.seconds = 2;
interval.nanoseconds = 0; interval.nanoseconds = 0;
INSIST(timer_create(timgr, timer_type_once, expires, interval, INSIST(isc_timer_create(timgr, isc_timertype_once, expires, interval,
t3, timeout, "3", &ti3) == ISC_R_SUCCESS); t3, timeout, "3", &ti3) == ISC_R_SUCCESS);
task_detach(&t1); task_detach(&t1);
task_detach(&t2); task_detach(&t2);
@@ -129,11 +129,11 @@ main(int argc, char *argv[]) {
sleep(15); sleep(15);
printf("destroy\n"); printf("destroy\n");
timer_detach(&ti1); isc_timer_detach(&ti1);
timer_detach(&ti2); isc_timer_detach(&ti2);
timer_detach(&ti3); isc_timer_detach(&ti3);
sleep(2); sleep(2);
timer_manager_destroy(&timgr); isc_timermgr_destroy(&timgr);
task_manager_destroy(&manager); task_manager_destroy(&manager);
printf("destroyed\n"); printf("destroyed\n");

View File

@@ -10,17 +10,16 @@
* An event class is a 16 bit number, the most sigificant bit of which must be * An event class is a 16 bit number, the most sigificant bit of which must be
* zero. Each class may contain up to 65536 events. An event type is * zero. Each class may contain up to 65536 events. An event type is
* formed by adding the event number within the class to the class number. * formed by adding the event number within the class to the class number.
* E.g., the first event in the timer class is EVENT_CLASS_TIMER + 1. Event * E.g., the first event in the timer class is ISC_EVENTCLASS_TIMER + 1.
* number zero is always reserved in each class. * Event number zero is always reserved in each class.
*/ */
#define EVENT_CLASS(class) ((class) << 16) #define ISC_EVENTCLASS(class) ((class) << 16)
#define EVENT_CLASS_TASK EVENT_CLASS(0) #define ISC_EVENTCLASS_TASK ISC_EVENTCLASS(0)
#define ISC_EVENTCLASS_TIMER ISC_EVENTCLASS(1)
#define EVENT_CLASS_TIMER EVENT_CLASS(1) #define ISC_EVENTCLASS_SOCKET ISC_EVENTCLASS(2)
#define EVENT_CLASS_SOCKET EVENT_CLASS(2) #define ISC_EVENTCLASS_FILE ISC_EVENTCLASS(3)
#define EVENT_CLASS_FILE EVENT_CLASS(3)
/* /*
* Event classes >= 1024 and <= 32767 are reserved for application use. * Event classes >= 1024 and <= 32767 are reserved for application use.

View File

@@ -2,7 +2,10 @@
#ifndef ISC_RESULT_H #ifndef ISC_RESULT_H
#define ISC_RESULT_H 1 #define ISC_RESULT_H 1
typedef unsigned int isc_result; /* XXX HACK XXX */
#define isc_result isc_result_t
typedef unsigned int isc_result_t;
#define ISC_R_SUCCESS 0 #define ISC_R_SUCCESS 0
#define ISC_R_NOMEMORY 1 #define ISC_R_NOMEMORY 1

View File

@@ -32,7 +32,7 @@
* making a call that affects that timer. Failure to follow this rule * making a call that affects that timer. Failure to follow this rule
* can result in deadlock. * can result in deadlock.
* *
* The caller must ensure that timer_manager_destroy() is called only * The caller must ensure that isc_timermgr_destroy() is called only
* once for a given manager. * once for a given manager.
* *
* Reliability: * Reliability:
@@ -64,39 +64,39 @@
*** Types *** Types
***/ ***/
typedef struct timer_t *timer_t; typedef struct isc_timer *isc_timer_t;
typedef struct timer_manager_t *timer_manager_t; typedef struct isc_timermgr *isc_timermgr_t;
typedef enum { typedef enum {
timer_type_ticker = 0, timer_type_once isc_timertype_ticker = 0, isc_timertype_once
} timer_type_t; } isc_timertype_t;
typedef struct timer_event { typedef struct isc_timerevent {
struct task_event common; struct task_event common;
/* XXX Anything else? XXX */ /* XXX Anything else? XXX */
} *timer_event_t; } *isc_timerevent_t;
#define TIMER_EVENT_TICK (EVENT_CLASS_TIMER + 1) #define ISC_TIMEREVENT_TICK (ISC_EVENTCLASS_TIMER + 1)
#define TIMER_EVENT_IDLE (EVENT_CLASS_TIMER + 2) #define ISC_TIMEREVENT_IDLE (ISC_EVENTCLASS_TIMER + 2)
#define TIMER_EVENT_LIFE (EVENT_CLASS_TIMER + 3) #define ISC_TIMEREVENT_LIFE (ISC_EVENTCLASS_TIMER + 3)
/*** /***
*** Timer and Timer Manager Functions *** Timer and Timer Manager Functions
*** ***
*** Note: all Ensures conditions apply only if the result is success for *** Note: all Ensures conditions apply only if the result is success for
*** those functions which return an isc_result. *** those functions which return an isc_result_t.
***/ ***/
isc_result isc_result_t
timer_create(timer_manager_t manager, isc_timer_create(isc_timermgr_t manager,
timer_type_t type, isc_timertype_t type,
os_time_t expires, os_time_t expires,
os_time_t interval, os_time_t interval,
task_t task, task_t task,
task_action_t action, task_action_t action,
void *arg, void *arg,
timer_t *timerp); isc_timer_t *timerp);
/* /*
* Create a new 'type' timer managed by 'manager'. The timers parameters * Create a new 'type' timer managed by 'manager'. The timers parameters
* are specified by 'expires' and 'interval'. Events will be posted to * are specified by 'expires' and 'interval'. Events will be posted to
@@ -143,12 +143,12 @@ timer_create(timer_manager_t manager,
* Unexpected error * Unexpected error
*/ */
isc_result isc_result_t
timer_reset(timer_t timer, isc_timer_reset(isc_timer_t timer,
timer_type_t type, isc_timertype_t type,
os_time_t expires, os_time_t expires,
os_time_t interval, os_time_t interval,
isc_boolean_t purge); isc_boolean_t purge);
/* /*
* Change the timer's type, expires, and interval values to the given * Change the timer's type, expires, and interval values to the given
* values. If 'purge' is TRUE, any pending events from this timer * values. If 'purge' is TRUE, any pending events from this timer
@@ -158,7 +158,7 @@ timer_reset(timer_t timer,
* *
* 'timer' is a valid timer * 'timer' is a valid timer
* *
* The same requirements that timer_create() imposes on 'type', * The same requirements that isc_timer_create() imposes on 'type',
* 'expires' and 'interval' apply. * 'expires' and 'interval' apply.
* *
* Ensures: * Ensures:
@@ -174,8 +174,8 @@ timer_reset(timer_t timer,
* Unexpected error * Unexpected error
*/ */
isc_result isc_result_t
timer_touch(timer_t timer); isc_timer_touch(isc_timer_t timer);
/* /*
* Set the last-touched time of 'timer' to the current time. * Set the last-touched time of 'timer' to the current time.
* *
@@ -196,7 +196,7 @@ timer_touch(timer_t timer);
*/ */
void void
timer_attach(timer_t timer, timer_t *timerp); isc_timer_attach(isc_timer_t timer, isc_timer_t *timerp);
/* /*
* Attach *timerp to timer. * Attach *timerp to timer.
* *
@@ -212,7 +212,7 @@ timer_attach(timer_t timer, timer_t *timerp);
*/ */
void void
timer_detach(timer_t *timerp); isc_timer_detach(isc_timer_t *timerp);
/* /*
* Detach *timerp from its timer. * Detach *timerp from its timer.
* *
@@ -234,8 +234,8 @@ timer_detach(timer_t *timerp);
* All resources used by the timer have been freed * All resources used by the timer have been freed
*/ */
isc_result isc_result_t
timer_manager_create(mem_context_t mctx, timer_manager_t *managerp); isc_timermgr_create(mem_context_t mctx, isc_timermgr_t *managerp);
/* /*
* Create a timer manager. * Create a timer manager.
* *
@@ -247,11 +247,11 @@ timer_manager_create(mem_context_t mctx, timer_manager_t *managerp);
* *
* 'mctx' is a valid memory context. * 'mctx' is a valid memory context.
* *
* 'managerp' points to a NULL timer_manager_t. * 'managerp' points to a NULL isc_timermgr_t.
* *
* Ensures: * Ensures:
* *
* '*managerp' is a valid timer_manager_t. * '*managerp' is a valid isc_timermgr_t.
* *
* Returns: * Returns:
* *
@@ -261,7 +261,7 @@ timer_manager_create(mem_context_t mctx, timer_manager_t *managerp);
*/ */
void void
timer_manager_destroy(timer_manager_t *); isc_timermgr_destroy(isc_timermgr_t *);
/* /*
* Destroy a timer manager. * Destroy a timer manager.
* *
@@ -269,12 +269,12 @@ timer_manager_destroy(timer_manager_t *);
* *
* This routine blocks until there are no timers left in the manager, * This routine blocks until there are no timers left in the manager,
* so if the caller holds any timer references using the manager, it * so if the caller holds any timer references using the manager, it
* must detach them before calling timer_manager_destroy() or it will * must detach them before calling isc_timermgr_destroy() or it will
* block forever. * block forever.
* *
* Requires: * Requires:
* *
* '*managerp' is a valid timer_manager_t. * '*managerp' is a valid isc_timermgr_t.
* *
* Ensures: * Ensures:
* *

View File

@@ -27,7 +27,7 @@
#define ZERO(t) ((t).seconds == 0 && \ #define ZERO(t) ((t).seconds == 0 && \
(t).nanoseconds == 0) (t).nanoseconds == 0)
#ifdef TIMER_TRACE #ifdef ISC_TIMER_TRACE
#define XTRACE(s) printf("%s\n", (s)) #define XTRACE(s) printf("%s\n", (s))
#define XTRACEID(s, t) printf("%s %p\n", (s), (t)) #define XTRACEID(s, t) printf("%s %p\n", (s), (t))
#define XTRACETIME(s, d) printf("%s %lu.%09lu\n", (s), \ #define XTRACETIME(s, d) printf("%s %lu.%09lu\n", (s), \
@@ -39,21 +39,21 @@
#define XTRACEID(s, t) #define XTRACEID(s, t)
#define XTRACETIME(s, d) #define XTRACETIME(s, d)
#define XTRACETIMER(s, t, d) #define XTRACETIMER(s, t, d)
#endif /* TIMER_TRACE */ #endif /* ISC_TIMER_TRACE */
#define TIMER_MAGIC 0x54494D52U /* TIMR. */ #define TIMER_MAGIC 0x54494D52U /* TIMR. */
#define VALID_TIMER(t) ((t) != NULL && \ #define VALID_TIMER(t) ((t) != NULL && \
(t)->magic == TIMER_MAGIC) (t)->magic == TIMER_MAGIC)
struct timer_t { struct isc_timer {
/* Not locked. */ /* Not locked. */
unsigned int magic; unsigned int magic;
timer_manager_t manager; isc_timermgr_t manager;
os_mutex_t lock; os_mutex_t lock;
/* Locked by timer lock. */ /* Locked by timer lock. */
unsigned int references; unsigned int references;
os_time_t idle; os_time_t idle;
/* Locked by manager lock. */ /* Locked by manager lock. */
timer_type_t type; isc_timertype_t type;
os_time_t expires; os_time_t expires;
os_time_t interval; os_time_t interval;
task_t task; task_t task;
@@ -61,21 +61,21 @@ struct timer_t {
void * arg; void * arg;
unsigned int index; unsigned int index;
os_time_t due; os_time_t due;
LINK(struct timer_t) link; LINK(struct isc_timer) link;
}; };
#define TIMER_MANAGER_MAGIC 0x54494D4DU /* TIMM. */ #define TIMER_MANAGER_MAGIC 0x54494D4DU /* TIMM. */
#define VALID_MANAGER(m) ((m) != NULL && \ #define VALID_MANAGER(m) ((m) != NULL && \
(m)->magic == TIMER_MANAGER_MAGIC) (m)->magic == TIMER_MANAGER_MAGIC)
struct timer_manager_t { struct isc_timermgr {
/* Not locked. */ /* Not locked. */
unsigned int magic; unsigned int magic;
mem_context_t mctx; mem_context_t mctx;
os_mutex_t lock; os_mutex_t lock;
/* Locked by manager lock. */ /* Locked by manager lock. */
isc_boolean_t done; isc_boolean_t done;
LIST(struct timer_t) timers; LIST(struct isc_timer) timers;
unsigned int nscheduled; unsigned int nscheduled;
os_time_t due; os_time_t due;
os_condition_t wakeup; os_condition_t wakeup;
@@ -84,9 +84,9 @@ struct timer_manager_t {
}; };
static inline isc_result static inline isc_result
schedule(timer_t timer, os_time_t *nowp, isc_boolean_t broadcast_ok) { schedule(isc_timer_t timer, os_time_t *nowp, isc_boolean_t broadcast_ok) {
isc_result result; isc_result result;
timer_manager_t manager; isc_timermgr_t manager;
os_time_t due; os_time_t due;
int cmp; int cmp;
@@ -97,7 +97,7 @@ schedule(timer_t timer, os_time_t *nowp, isc_boolean_t broadcast_ok) {
/* /*
* Compute the new due time. * Compute the new due time.
*/ */
if (timer->type == timer_type_ticker) if (timer->type == isc_timertype_ticker)
os_time_add(nowp, &timer->interval, &due); os_time_add(nowp, &timer->interval, &due);
else { else {
if (ZERO(timer->idle)) if (ZERO(timer->idle))
@@ -158,9 +158,9 @@ schedule(timer_t timer, os_time_t *nowp, isc_boolean_t broadcast_ok) {
} }
static inline void static inline void
deschedule(timer_t timer) { deschedule(isc_timer_t timer) {
isc_boolean_t need_wakeup = ISC_FALSE; isc_boolean_t need_wakeup = ISC_FALSE;
timer_manager_t manager; isc_timermgr_t manager;
/* /*
* The caller must ensure locking. * The caller must ensure locking.
@@ -182,8 +182,8 @@ deschedule(timer_t timer) {
} }
static void static void
destroy(timer_t timer) { destroy(isc_timer_t timer) {
timer_manager_t manager = timer->manager; isc_timermgr_t manager = timer->manager;
/* /*
* The caller must ensure locking. * The caller must ensure locking.
@@ -204,11 +204,12 @@ destroy(timer_t timer) {
} }
isc_result isc_result
timer_create(timer_manager_t manager, timer_type_t type, isc_timer_create(isc_timermgr_t manager, isc_timertype_t type,
os_time_t expires, os_time_t interval, os_time_t expires, os_time_t interval,
task_t task, task_action_t action, void *arg, timer_t *timerp) task_t task, task_action_t action, void *arg,
isc_timer_t *timerp)
{ {
timer_t timer; isc_timer_t timer;
isc_result result; isc_result result;
os_time_t now; os_time_t now;
@@ -244,7 +245,7 @@ timer_create(timer_manager_t manager, timer_type_t type,
timer->magic = TIMER_MAGIC; timer->magic = TIMER_MAGIC;
timer->manager = manager; timer->manager = manager;
timer->references = 1; timer->references = 1;
if (type == timer_type_once && !ZERO(interval)) if (type == isc_timertype_once && !ZERO(interval))
os_time_add(&now, &interval, &timer->idle); os_time_add(&now, &interval, &timer->idle);
else { else {
timer->idle.seconds = 0; timer->idle.seconds = 0;
@@ -283,11 +284,11 @@ timer_create(timer_manager_t manager, timer_type_t type,
} }
isc_result isc_result
timer_reset(timer_t timer, timer_type_t type, isc_timer_reset(isc_timer_t timer, isc_timertype_t type,
os_time_t expires, os_time_t interval, isc_boolean_t purge) os_time_t expires, os_time_t interval, isc_boolean_t purge)
{ {
os_time_t now; os_time_t now;
timer_manager_t manager; isc_timermgr_t manager;
isc_result result; isc_result result;
/* /*
@@ -322,7 +323,7 @@ timer_reset(timer_t timer, timer_type_t type,
timer->type = type; timer->type = type;
timer->expires = expires; timer->expires = expires;
timer->interval = interval; timer->interval = interval;
if (type == timer_type_once && !ZERO(interval)) if (type == isc_timertype_once && !ZERO(interval))
os_time_add(&now, &interval, &timer->idle); os_time_add(&now, &interval, &timer->idle);
else { else {
timer->idle.seconds = 0; timer->idle.seconds = 0;
@@ -337,7 +338,7 @@ timer_reset(timer_t timer, timer_type_t type,
} }
isc_result isc_result
timer_touch(timer_t timer) { isc_timer_touch(isc_timer_t timer) {
isc_result result; isc_result result;
os_time_t now; os_time_t now;
@@ -349,7 +350,7 @@ timer_touch(timer_t timer) {
LOCK(&timer->lock); LOCK(&timer->lock);
INSIST(timer->type == timer_type_once); INSIST(timer->type == isc_timertype_once);
result = os_time_get(&now); result = os_time_get(&now);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
@@ -366,7 +367,7 @@ timer_touch(timer_t timer) {
} }
void void
timer_attach(timer_t timer, timer_t *timerp) { isc_timer_attach(isc_timer_t timer, isc_timer_t *timerp) {
/* /*
* Attach *timerp to timer. * Attach *timerp to timer.
*/ */
@@ -382,8 +383,8 @@ timer_attach(timer_t timer, timer_t *timerp) {
} }
void void
timer_detach(timer_t *timerp) { isc_timer_detach(isc_timer_t *timerp) {
timer_t timer; isc_timer_t timer;
isc_boolean_t free_timer = ISC_FALSE; isc_boolean_t free_timer = ISC_FALSE;
/* /*
@@ -408,30 +409,30 @@ timer_detach(timer_t *timerp) {
} }
static void static void
dispatch(timer_manager_t manager, os_time_t *nowp) { dispatch(isc_timermgr_t manager, os_time_t *nowp) {
isc_boolean_t done = ISC_FALSE, post_event, need_schedule; isc_boolean_t done = ISC_FALSE, post_event, need_schedule;
task_event_t event; task_event_t event;
task_eventtype_t type = 0; task_eventtype_t type = 0;
timer_t timer; isc_timer_t timer;
isc_result result; isc_result result;
while (manager->nscheduled > 0 && !done) { while (manager->nscheduled > 0 && !done) {
timer = isc_heap_element(manager->heap, 1); timer = isc_heap_element(manager->heap, 1);
if (os_time_compare(nowp, &timer->due) >= 0) { if (os_time_compare(nowp, &timer->due) >= 0) {
if (timer->type == timer_type_ticker) { if (timer->type == isc_timertype_ticker) {
type = TIMER_EVENT_TICK; type = ISC_TIMEREVENT_TICK;
post_event = ISC_TRUE; post_event = ISC_TRUE;
need_schedule = ISC_TRUE; need_schedule = ISC_TRUE;
} else if (!ZERO(timer->expires) && } else if (!ZERO(timer->expires) &&
os_time_compare(nowp, os_time_compare(nowp,
&timer->expires) >= 0) { &timer->expires) >= 0) {
type = TIMER_EVENT_LIFE; type = ISC_TIMEREVENT_LIFE;
post_event = ISC_TRUE; post_event = ISC_TRUE;
need_schedule = ISC_FALSE; need_schedule = ISC_FALSE;
} else if (!ZERO(timer->idle) && } else if (!ZERO(timer->idle) &&
os_time_compare(nowp, os_time_compare(nowp,
&timer->idle) >= 0) { &timer->idle) >= 0) {
type = TIMER_EVENT_IDLE; type = ISC_TIMEREVENT_IDLE;
post_event = ISC_TRUE; post_event = ISC_TRUE;
need_schedule = ISC_FALSE; need_schedule = ISC_FALSE;
} else { } else {
@@ -480,7 +481,7 @@ dispatch(timer_manager_t manager, os_time_t *nowp) {
static void * static void *
run(void *uap) { run(void *uap) {
timer_manager_t manager = uap; isc_timermgr_t manager = uap;
isc_boolean_t timeout; isc_boolean_t timeout;
os_time_t now; os_time_t now;
@@ -509,7 +510,7 @@ run(void *uap) {
static isc_boolean_t static isc_boolean_t
sooner(void *v1, void *v2) { sooner(void *v1, void *v2) {
timer_t t1, t2; isc_timer_t t1, t2;
t1 = v1; t1 = v1;
t2 = v2; t2 = v2;
@@ -523,7 +524,7 @@ sooner(void *v1, void *v2) {
static void static void
set_index(void *what, unsigned int index) { set_index(void *what, unsigned int index) {
timer_t timer; isc_timer_t timer;
timer = what; timer = what;
REQUIRE(VALID_TIMER(timer)); REQUIRE(VALID_TIMER(timer));
@@ -532,8 +533,8 @@ set_index(void *what, unsigned int index) {
} }
isc_result isc_result
timer_manager_create(mem_context_t mctx, timer_manager_t *managerp) { isc_timermgr_create(mem_context_t mctx, isc_timermgr_t *managerp) {
timer_manager_t manager; isc_timermgr_t manager;
isc_result result; isc_result result;
/* /*
@@ -590,8 +591,8 @@ timer_manager_create(mem_context_t mctx, timer_manager_t *managerp) {
} }
void void
timer_manager_destroy(timer_manager_t *managerp) { isc_timermgr_destroy(isc_timermgr_t *managerp) {
timer_manager_t manager; isc_timermgr_t manager;
/* /*
* Destroy a timer manager. * Destroy a timer manager.