From c92ba071011bbc09e7146729606fd9e89a9be02c Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Wed, 21 Oct 1998 02:26:57 +0000 Subject: [PATCH] more renaming --- bin/tests/task_test.c | 126 +++++++++++++++++----------------- bin/tests/timer_test.c | 26 ++++---- lib/isc/include/isc/task.h | 77 ++++++++++----------- lib/isc/include/isc/timer.h | 6 +- lib/isc/task.c | 130 ++++++++++++++++++------------------ lib/isc/timer.c | 34 +++++----- 6 files changed, 200 insertions(+), 199 deletions(-) diff --git a/bin/tests/task_test.c b/bin/tests/task_test.c index 12d405cf51..27913adad7 100644 --- a/bin/tests/task_test.c +++ b/bin/tests/task_test.c @@ -14,7 +14,7 @@ mem_context_t mctx = NULL; static isc_boolean_t -my_callback(task_t task, task_event_t event) +my_callback(isc_task_t task, isc_event_t event) { int i, j; char *name = event->arg; @@ -28,7 +28,7 @@ my_callback(task_t task, task_event_t event) } static isc_boolean_t -my_shutdown(task_t task, task_event_t event) { +my_shutdown(isc_task_t task, isc_event_t event) { char *name = event->arg; printf("shutdown %s (%p)\n", name, task); @@ -36,7 +36,7 @@ my_shutdown(task_t task, task_event_t event) { } static isc_boolean_t -my_tick(task_t task, task_event_t event) +my_tick(isc_task_t task, isc_event_t event) { char *name = event->arg; @@ -46,10 +46,10 @@ my_tick(task_t task, task_event_t event) void main(int argc, char *argv[]) { - task_manager_t manager = NULL; - task_t t1 = NULL, t2 = NULL; - task_t t3 = NULL, t4 = NULL; - task_event_t event; + isc_taskmgr_t manager = NULL; + isc_task_t t1 = NULL, t2 = NULL; + isc_task_t t3 = NULL, t4 = NULL; + isc_event_t event; unsigned int workers; isc_timermgr_t timgr; isc_timer_t ti1, ti2; @@ -63,12 +63,12 @@ main(int argc, char *argv[]) { INSIST(mem_context_create(0, 0, &mctx) == 0); - INSIST(task_manager_create(mctx, workers, 0, &manager) == workers); + INSIST(isc_taskmgr_create(mctx, workers, 0, &manager) == workers); - INSIST(task_create(manager, my_shutdown, "1", 0, &t1)); - INSIST(task_create(manager, my_shutdown, "2", 0, &t2)); - INSIST(task_create(manager, my_shutdown, "3", 0, &t3)); - INSIST(task_create(manager, my_shutdown, "4", 0, &t4)); + INSIST(isc_task_create(manager, my_shutdown, "1", 0, &t1)); + INSIST(isc_task_create(manager, my_shutdown, "2", 0, &t2)); + INSIST(isc_task_create(manager, my_shutdown, "3", 0, &t3)); + INSIST(isc_task_create(manager, my_shutdown, "4", 0, &t4)); timgr = NULL; INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS); @@ -89,64 +89,64 @@ main(int argc, char *argv[]) { printf("task 2 = %p\n", t2); sleep(2); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "1", - sizeof *event); - task_send_event(t1, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "2", - sizeof *event); - task_send_event(t2, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "3", - sizeof *event); - task_send_event(t3, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "4", - sizeof *event); - task_send_event(t4, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "2", - sizeof *event); - task_send_event(t2, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "3", - sizeof *event); - task_send_event(t3, &event); - event = task_event_allocate(mctx, main, 1, my_callback, "4", - sizeof *event); - task_send_event(t4, &event); - task_purge_events(t3, NULL, 0); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "1", + sizeof *event); + isc_task_send(t1, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "2", + sizeof *event); + isc_task_send(t2, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "3", + sizeof *event); + isc_task_send(t3, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "4", + sizeof *event); + isc_task_send(t4, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "2", + sizeof *event); + isc_task_send(t2, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "3", + sizeof *event); + isc_task_send(t3, &event); + event = isc_event_allocate(mctx, main, 1, my_callback, "4", + sizeof *event); + isc_task_send(t4, &event); + isc_task_purge(t3, NULL, 0); - task_detach(&t1); - task_detach(&t2); - task_detach(&t3); - task_detach(&t4); + isc_task_detach(&t1); + isc_task_detach(&t2); + isc_task_detach(&t3); + isc_task_detach(&t4); sleep(10); printf("destroy\n"); isc_timer_detach(&ti1); isc_timer_detach(&ti2); isc_timermgr_destroy(&timgr); - task_manager_destroy(&manager); + isc_taskmgr_destroy(&manager); printf("destroyed\n"); mem_stats(mctx, stdout); diff --git a/bin/tests/timer_test.c b/bin/tests/timer_test.c index cc72910353..72bd75c942 100644 --- a/bin/tests/timer_test.c +++ b/bin/tests/timer_test.c @@ -12,12 +12,12 @@ #include mem_context_t mctx = NULL; -task_t t1, t2, t3; +isc_task_t t1, t2, t3; isc_timer_t ti1, ti2, ti3; int tick_count = 0; static isc_boolean_t -shutdown_task(task_t task, task_event_t event) { +shutdown_task(isc_task_t task, isc_event_t event) { char *name = event->arg; printf("task %p shutdown %s\n", task, name); @@ -25,7 +25,7 @@ shutdown_task(task_t task, task_event_t event) { } static isc_boolean_t -tick(task_t task, task_event_t event) +tick(isc_task_t task, isc_event_t event) { char *name = event->arg; @@ -56,7 +56,7 @@ tick(task_t task, task_event_t event) } static isc_boolean_t -timeout(task_t task, task_event_t event) +timeout(isc_task_t task, isc_event_t event) { char *name = event->arg; char *type; @@ -79,7 +79,7 @@ timeout(task_t task, task_event_t event) void main(int argc, char *argv[]) { - task_manager_t manager = NULL; + isc_taskmgr_t manager = NULL; isc_timermgr_t timgr = NULL; unsigned int workers; os_time_t expires, interval, now; @@ -91,10 +91,10 @@ main(int argc, char *argv[]) { printf("%d workers\n", workers); INSIST(mem_context_create(0, 0, &mctx) == 0); - INSIST(task_manager_create(mctx, workers, 0, &manager) == workers); - INSIST(task_create(manager, shutdown_task, "1", 0, &t1)); - INSIST(task_create(manager, shutdown_task, "2", 0, &t2)); - INSIST(task_create(manager, shutdown_task, "3", 0, &t3)); + INSIST(isc_taskmgr_create(mctx, workers, 0, &manager) == workers); + INSIST(isc_task_create(manager, shutdown_task, "1", 0, &t1)); + INSIST(isc_task_create(manager, shutdown_task, "2", 0, &t2)); + INSIST(isc_task_create(manager, shutdown_task, "3", 0, &t3)); INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS); printf("task 1: %p\n", t1); @@ -123,9 +123,9 @@ main(int argc, char *argv[]) { INSIST(isc_timer_create(timgr, isc_timertype_once, expires, interval, t3, timeout, "3", &ti3) == ISC_R_SUCCESS); - task_detach(&t1); - task_detach(&t2); - task_detach(&t3); + isc_task_detach(&t1); + isc_task_detach(&t2); + isc_task_detach(&t3); sleep(15); printf("destroy\n"); @@ -134,7 +134,7 @@ main(int argc, char *argv[]) { isc_timer_detach(&ti3); sleep(2); isc_timermgr_destroy(&timgr); - task_manager_destroy(&manager); + isc_taskmgr_destroy(&manager); printf("destroyed\n"); mem_stats(mctx, stdout); diff --git a/lib/isc/include/isc/task.h b/lib/isc/include/isc/task.h index e7e7f35674..251c5ff648 100644 --- a/lib/isc/include/isc/task.h +++ b/lib/isc/include/isc/task.h @@ -1,6 +1,6 @@ -#ifndef TASK_H -#define TASK_H 1 +#ifndef ISC_TASK_H +#define ISC_TASK_H 1 #include @@ -14,9 +14,9 @@ *** Core Types. ***/ -typedef struct task_event * task_event_t; -typedef struct task * task_t; -typedef struct task_manager * task_manager_t; +typedef struct isc_event * isc_event_t; +typedef struct isc_task * isc_task_t; +typedef struct isc_taskmgr * isc_taskmgr_t; /*** @@ -28,64 +28,65 @@ typedef struct task_manager * task_manager_t; * * Type 0 means "any type". */ -typedef int task_eventtype_t; +typedef int isc_eventtype_t; -typedef isc_boolean_t (*task_action_t)(task_t, task_event_t); +typedef isc_boolean_t (*isc_taskaction_t)(isc_task_t, isc_event_t); /* * This structure is public because "subclassing" it may be useful when * defining new event types. */ -struct task_event { +struct isc_event { mem_context_t mctx; size_t size; void * sender; - task_eventtype_t type; - task_action_t action; + isc_eventtype_t type; + isc_taskaction_t action; void * arg; - LINK(struct task_event) link; + LINK(struct isc_event) link; }; -#define TASK_EVENT_ANYEVENT 0 -#define TASK_EVENT_SHUTDOWN (-1) +#define ISC_TASKEVENT_ANYEVENT 0 +#define ISC_TASKEVENT_SHUTDOWN (-1) -typedef LIST(struct task_event) task_eventlist_t; +typedef LIST(struct isc_event) isc_eventlist_t; -task_event_t task_event_allocate(mem_context_t, - void *, - task_eventtype_t, - task_action_t, - void *arg, - size_t); -void task_event_free(task_event_t *); +isc_event_t isc_event_allocate(mem_context_t, + void *, + isc_eventtype_t, + isc_taskaction_t, + void *arg, + size_t); +void isc_event_free(isc_event_t *); /*** *** Tasks. ***/ -isc_boolean_t task_create(task_manager_t, - task_action_t, +isc_boolean_t isc_task_create(isc_taskmgr_t, + isc_taskaction_t, void *, unsigned int, - task_t *); -void task_attach(task_t, task_t *); -void task_detach(task_t *); -isc_boolean_t task_send_event(task_t, - task_event_t *); -void task_purge_events(task_t, void *, - task_eventtype_t); -void task_shutdown(task_t); -void task_destroy(task_t *); + isc_task_t *); +void isc_task_attach(isc_task_t, + isc_task_t *); +void isc_task_detach(isc_task_t *); +isc_boolean_t isc_task_send(isc_task_t, + isc_event_t *); +void isc_task_purge(isc_task_t, void *, + isc_eventtype_t); +void isc_task_shutdown(isc_task_t); +void isc_task_destroy(isc_task_t *); /*** *** Task Manager. ***/ -unsigned int task_manager_create(mem_context_t, - unsigned int, - unsigned int, - task_manager_t *); -void task_manager_destroy(task_manager_t *); +unsigned int isc_taskmgr_create(mem_context_t, + unsigned int, + unsigned int, + isc_taskmgr_t *); +void isc_taskmgr_destroy(isc_taskmgr_t *); -#endif /* TASK_H */ +#endif /* ISC_TASK_H */ diff --git a/lib/isc/include/isc/timer.h b/lib/isc/include/isc/timer.h index 709129bbb3..42fae6a166 100644 --- a/lib/isc/include/isc/timer.h +++ b/lib/isc/include/isc/timer.h @@ -72,7 +72,7 @@ typedef enum { } isc_timertype_t; typedef struct isc_timerevent { - struct task_event common; + struct isc_event common; /* XXX Anything else? XXX */ } *isc_timerevent_t; @@ -93,8 +93,8 @@ isc_timer_create(isc_timermgr_t manager, isc_timertype_t type, os_time_t expires, os_time_t interval, - task_t task, - task_action_t action, + isc_task_t task, + isc_taskaction_t action, void *arg, isc_timer_t *timerp); /* diff --git a/lib/isc/task.c b/lib/isc/task.c index b43dd4b3c3..3156e91edf 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -26,7 +26,7 @@ #define WAIT(cvp, lp) INSIST(os_condition_wait((cvp), (lp))) #define BROADCAST(cvp) INSIST(os_condition_broadcast((cvp))) -#ifdef TASK_TRACE +#ifdef ISC_TASK_TRACE #define XTRACE(m) printf("%s task %p thread %p\n", (m), \ task, os_thread_self()) #else @@ -47,36 +47,36 @@ typedef enum { #define VALID_TASK(t) ((t) != NULL && \ (t)->magic == TASK_MAGIC) -struct task { +struct isc_task { /* Not locked. */ unsigned int magic; - task_manager_t manager; + isc_taskmgr_t manager; os_mutex_t lock; /* Locked by task lock. */ task_state_t state; unsigned int references; - task_eventlist_t events; + isc_eventlist_t events; unsigned int quantum; isc_boolean_t enqueue_allowed; - task_event_t shutdown_event; + isc_event_t shutdown_event; /* Locked by task manager lock. */ - LINK(struct task) link; - LINK(struct task) ready_link; + LINK(struct isc_task) link; + LINK(struct isc_task) ready_link; }; #define TASK_MANAGER_MAGIC 0x54534B4DU /* TSKM. */ #define VALID_MANAGER(m) ((m) != NULL && \ (m)->magic == TASK_MANAGER_MAGIC) -struct task_manager { +struct isc_taskmgr { /* Not locked. */ unsigned int magic; mem_context_t mctx; os_mutex_t lock; /* Locked by task manager lock. */ unsigned int default_quantum; - LIST(struct task) tasks; - LIST(struct task) ready_tasks; + LIST(struct isc_task) tasks; + LIST(struct isc_task) ready_tasks; os_condition_t work_available; isc_boolean_t exiting; unsigned int workers; @@ -91,11 +91,11 @@ struct task_manager { *** Events. ***/ -static inline task_event_t -event_allocate(mem_context_t mctx, void *sender, task_eventtype_t type, - task_action_t action, void *arg, size_t size) +static inline isc_event_t +event_allocate(mem_context_t mctx, void *sender, isc_eventtype_t type, + isc_taskaction_t action, void *arg, size_t size) { - task_event_t event; + isc_event_t event; event = mem_get(mctx, size); if (event == NULL) @@ -110,11 +110,11 @@ event_allocate(mem_context_t mctx, void *sender, task_eventtype_t type, return (event); } -task_event_t -task_event_allocate(mem_context_t mctx, void *sender, task_eventtype_t type, - task_action_t action, void *arg, size_t size) +isc_event_t +isc_event_allocate(mem_context_t mctx, void *sender, isc_eventtype_t type, + isc_taskaction_t action, void *arg, size_t size) { - if (size < sizeof (struct task_event)) + if (size < sizeof (struct isc_event)) return (NULL); if (type < 0) return (NULL); @@ -125,8 +125,8 @@ task_event_allocate(mem_context_t mctx, void *sender, task_eventtype_t type, } void -task_event_free(task_event_t *eventp) { - task_event_t event; +isc_event_free(isc_event_t *eventp) { + isc_event_t event; REQUIRE(eventp != NULL); event = *eventp; @@ -142,8 +142,8 @@ task_event_free(task_event_t *eventp) { ***/ static void -task_free(task_t task) { - task_manager_t manager = task->manager; +task_free(isc_task_t task) { + isc_taskmgr_t manager = task->manager; XTRACE("free task"); REQUIRE(EMPTY(task->events)); @@ -162,16 +162,16 @@ task_free(task_t task) { UNLOCK(&manager->lock); (void)os_mutex_destroy(&task->lock); if (task->shutdown_event != NULL) - task_event_free(&task->shutdown_event); + isc_event_free(&task->shutdown_event); task->magic = 0; mem_put(manager->mctx, task, sizeof *task); } isc_boolean_t -task_create(task_manager_t manager, task_action_t shutdown_action, - void *shutdown_arg, unsigned int quantum, task_t *taskp) +isc_task_create(isc_taskmgr_t manager, isc_taskaction_t shutdown_action, + void *shutdown_arg, unsigned int quantum, isc_task_t *taskp) { - task_t task; + isc_task_t task; REQUIRE(VALID_MANAGER(manager)); REQUIRE(taskp != NULL && *taskp == NULL); @@ -193,7 +193,7 @@ task_create(task_manager_t manager, task_action_t shutdown_action, task->enqueue_allowed = ISC_TRUE; task->shutdown_event = event_allocate(manager->mctx, NULL, - TASK_EVENT_SHUTDOWN, + ISC_TASKEVENT_SHUTDOWN, shutdown_action, shutdown_arg, sizeof *task->shutdown_event); @@ -217,7 +217,7 @@ task_create(task_manager_t manager, task_action_t shutdown_action, } void -task_attach(task_t task, task_t *taskp) { +isc_task_attach(isc_task_t task, isc_task_t *taskp) { REQUIRE(VALID_TASK(task)); REQUIRE(taskp != NULL && *taskp == NULL); @@ -230,11 +230,11 @@ task_attach(task_t task, task_t *taskp) { } void -task_detach(task_t *taskp) { +isc_task_detach(isc_task_t *taskp) { isc_boolean_t free_task = ISC_FALSE; - task_t task; + isc_task_t task; - XTRACE("task_detach"); + XTRACE("isc_task_detach"); REQUIRE(taskp != NULL); task = *taskp; @@ -254,10 +254,10 @@ task_detach(task_t *taskp) { } isc_boolean_t -task_send_event(task_t task, task_event_t *eventp) { +isc_task_send(isc_task_t task, isc_event_t *eventp) { isc_boolean_t was_idle = ISC_FALSE; isc_boolean_t discard = ISC_FALSE; - task_event_t event; + isc_event_t event; REQUIRE(VALID_TASK(task)); REQUIRE(eventp != NULL); @@ -287,14 +287,14 @@ task_send_event(task_t task, task_event_t *eventp) { UNLOCK(&task->lock); if (discard) { - task_event_free(&event); + isc_event_free(&event); *eventp = NULL; return (ISC_TRUE); } if (was_idle) { isc_boolean_t need_wakeup = ISC_FALSE; - task_manager_t manager; + isc_taskmgr_t manager; /* * We need to add this task to the ready queue. @@ -339,9 +339,9 @@ task_send_event(task_t task, task_event_t *eventp) { } void -task_purge_events(task_t task, void *sender, task_eventtype_t type) { - task_event_t event, next_event; - task_eventlist_t purgeable; +isc_task_purge(isc_task_t task, void *sender, isc_eventtype_t type) { + isc_event_t event, next_event; + isc_eventlist_t purgeable; REQUIRE(VALID_TASK(task)); REQUIRE(type >= 0); @@ -371,19 +371,19 @@ task_purge_events(task_t task, void *sender, task_eventtype_t type) { event != NULL; event = next_event) { next_event = NEXT(event, link); - task_event_free(&event); + isc_event_free(&event); } } void -task_shutdown(task_t task) { +isc_task_shutdown(isc_task_t task) { isc_boolean_t was_idle = ISC_FALSE; isc_boolean_t discard = ISC_FALSE; REQUIRE(VALID_TASK(task)); /* - * This routine is very similar to task_send_event() above. + * This routine is very similar to isc_task_send_event() above. */ LOCK(&task->lock); @@ -408,7 +408,7 @@ task_shutdown(task_t task) { if (was_idle) { isc_boolean_t need_wakeup = ISC_FALSE; - task_manager_t manager; + isc_taskmgr_t manager; manager = task->manager; INSIST(VALID_MANAGER(manager)); @@ -424,12 +424,12 @@ task_shutdown(task_t task) { } void -task_destroy(task_t *taskp) { +isc_task_destroy(isc_task_t *taskp) { REQUIRE(taskp != NULL); - task_shutdown(*taskp); - task_detach(taskp); + isc_task_shutdown(*taskp); + isc_task_detach(taskp); } @@ -439,9 +439,9 @@ task_destroy(task_t *taskp) { ***/ static -void *task_manager_run(void *uap) { - task_manager_t manager = uap; - task_t task; +void *run(void *uap) { + isc_taskmgr_t manager = uap; + isc_task_t task; isc_boolean_t no_workers = ISC_FALSE; XTRACE("start"); @@ -502,7 +502,7 @@ void *task_manager_run(void *uap) { while (!FINISHED(manager)) { /* * For reasons similar to those given in the comment in - * task_send_event() above, it is safe for us to dequeue + * isc_task_send_event() above, it is safe for us to dequeue * the task while only holding the manager lock, and then * change the task to running state while only holding the * task lock. @@ -522,8 +522,8 @@ void *task_manager_run(void *uap) { isc_boolean_t wants_shutdown; isc_boolean_t is_shutdown; isc_boolean_t free_task = ISC_FALSE; - task_event_t event; - task_eventlist_t remaining_events; + isc_event_t event; + isc_eventlist_t remaining_events; isc_boolean_t discard_remaining = ISC_FALSE; INSIST(VALID_TASK(task)); @@ -555,7 +555,7 @@ void *task_manager_run(void *uap) { DEQUEUE(task->events, event, link); UNLOCK(&task->lock); - if (event->type == TASK_EVENT_SHUTDOWN) + if (event->type == ISC_TASKEVENT_SHUTDOWN) is_shutdown = ISC_TRUE; else is_shutdown = ISC_FALSE; @@ -571,7 +571,7 @@ void *task_manager_run(void *uap) { wants_shutdown = ISC_FALSE; dispatch_count++; - task_event_free(&event); + isc_event_free(&event); LOCK(&task->lock); if (wants_shutdown || is_shutdown) { @@ -630,13 +630,13 @@ void *task_manager_run(void *uap) { UNLOCK(&task->lock); if (discard_remaining) { - task_event_t next_event; + isc_event_t next_event; for (event = HEAD(remaining_events); event != NULL; event = next_event) { next_event = NEXT(event, link); - task_event_free(&event); + isc_event_free(&event); } } @@ -684,7 +684,7 @@ void *task_manager_run(void *uap) { } static void -manager_free(task_manager_t manager) { +manager_free(isc_taskmgr_t manager) { (void)os_condition_destroy(&manager->work_available); (void)os_condition_destroy(&manager->no_workers); (void)os_mutex_destroy(&manager->lock); @@ -693,11 +693,11 @@ manager_free(task_manager_t manager) { } unsigned int -task_manager_create(mem_context_t mctx, unsigned int workers, - unsigned int default_quantum, task_manager_t *managerp) +isc_taskmgr_create(mem_context_t mctx, unsigned int workers, + unsigned int default_quantum, isc_taskmgr_t *managerp) { unsigned int i, started = 0; - task_manager_t manager; + isc_taskmgr_t manager; os_thread_t thread; if (workers == 0) @@ -735,7 +735,7 @@ task_manager_create(mem_context_t mctx, unsigned int workers, * Start workers. */ for (i = 0; i < workers; i++) { - if (os_thread_create(task_manager_run, manager, &thread)) { + if (os_thread_create(run, manager, &thread)) { manager->workers++; started++; (void)os_thread_detach(thread); @@ -754,20 +754,20 @@ task_manager_create(mem_context_t mctx, unsigned int workers, } void -task_manager_destroy(task_manager_t *managerp) { - task_manager_t manager; - task_t task; +isc_taskmgr_destroy(isc_taskmgr_t *managerp) { + isc_taskmgr_t manager; + isc_task_t task; REQUIRE(managerp != NULL); manager = *managerp; REQUIRE(VALID_MANAGER(manager)); - XTRACE("task_manager_destroy"); + XTRACE("isc_taskmgr_destroy"); /* * Only one non-worker thread may ever call this routine. * If a worker thread wants to initiate shutdown of the * task manager, it should ask some non-worker thread to call - * task_manager_destroy(), e.g. by signalling a condition variable + * isc_taskmgr_destroy(), e.g. by signalling a condition variable * that the startup thread is sleeping on. */ diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 9fd5e9952a..09d907c4a1 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -56,8 +56,8 @@ struct isc_timer { isc_timertype_t type; os_time_t expires; os_time_t interval; - task_t task; - task_action_t action; + isc_task_t task; + isc_taskaction_t action; void * arg; unsigned int index; os_time_t due; @@ -191,13 +191,13 @@ destroy(isc_timer_t timer) { LOCK(&manager->lock); - task_purge_events(timer->task, timer, TASK_EVENT_ANYEVENT); + isc_task_purge(timer->task, timer, ISC_TASKEVENT_ANYEVENT); deschedule(timer); UNLINK(manager->timers, timer, link); UNLOCK(&manager->lock); - task_detach(&timer->task); + isc_task_detach(&timer->task); (void)os_mutex_destroy(&timer->lock); timer->magic = 0; mem_put(manager->mctx, timer, sizeof *timer); @@ -206,7 +206,7 @@ destroy(isc_timer_t timer) { isc_result isc_timer_create(isc_timermgr_t manager, isc_timertype_t type, os_time_t expires, os_time_t interval, - task_t task, task_action_t action, void *arg, + isc_task_t task, isc_taskaction_t action, void *arg, isc_timer_t *timerp) { isc_timer_t timer; @@ -255,7 +255,7 @@ isc_timer_create(isc_timermgr_t manager, isc_timertype_t type, timer->expires = expires; timer->interval = interval; timer->task = NULL; - task_attach(task, &timer->task); + isc_task_attach(task, &timer->task); timer->action = action; timer->arg = arg; timer->index = 0; @@ -319,7 +319,7 @@ isc_timer_reset(isc_timer_t timer, isc_timertype_t type, LOCK(&timer->lock); if (purge) - task_purge_events(timer->task, timer, TASK_EVENT_ANYEVENT); + isc_task_purge(timer->task, timer, ISC_TASKEVENT_ANYEVENT); timer->type = type; timer->expires = expires; timer->interval = interval; @@ -411,8 +411,8 @@ isc_timer_detach(isc_timer_t *timerp) { static void dispatch(isc_timermgr_t manager, os_time_t *nowp) { isc_boolean_t done = ISC_FALSE, post_event, need_schedule; - task_event_t event; - task_eventtype_t type = 0; + isc_event_t event; + isc_eventtype_t type = 0; isc_timer_t timer; isc_result result; @@ -446,16 +446,16 @@ dispatch(isc_timermgr_t manager, os_time_t *nowp) { if (post_event) { XTRACEID("posting", timer); - event = task_event_allocate(manager->mctx, - timer, - type, - timer->action, - timer->arg, - sizeof *event); + event = isc_event_allocate(manager->mctx, + timer, + type, + timer->action, + timer->arg, + sizeof *event); if (event != NULL) - INSIST(task_send_event(timer->task, - &event)); + INSIST(isc_task_send(timer->task, + &event)); else UNEXPECTED_ERROR(__FILE__, __LINE__, "couldn't allocate event");