mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Remove layering from isc_task, isc_app, isc_socket, isc_timer, isc_mem
This commit is contained in:
389
lib/isc/task.c
389
lib/isc/task.c
@@ -152,6 +152,12 @@ struct isc__taskmgr {
|
||||
isc__task_t *excl;
|
||||
};
|
||||
|
||||
void
|
||||
isc__taskmgr_pause(isc_taskmgr_t *manager0);
|
||||
void
|
||||
isc__taskmgr_resume(isc_taskmgr_t *manager0);
|
||||
|
||||
|
||||
#define DEFAULT_TASKMGR_QUANTUM 10
|
||||
#define DEFAULT_DEFAULT_QUANTUM 5
|
||||
#define FINISHED(m) ((m)->exiting && EMPTY((m)->tasks))
|
||||
@@ -162,71 +168,12 @@ struct isc__taskmgr {
|
||||
* unit tests etc.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
isc_task_t **taskp);
|
||||
void
|
||||
isc__task_attach(isc_task_t *source0, isc_task_t **targetp);
|
||||
void
|
||||
isc__task_detach(isc_task_t **taskp);
|
||||
void
|
||||
isc__task_send(isc_task_t *task0, isc_event_t **eventp);
|
||||
void
|
||||
isc__task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp);
|
||||
unsigned int
|
||||
isc__task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag);
|
||||
unsigned int
|
||||
isc__task_purge(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag);
|
||||
bool
|
||||
isc_task_purgeevent(isc_task_t *task0, isc_event_t *event);
|
||||
unsigned int
|
||||
isc__task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag,
|
||||
isc_eventlist_t *events);
|
||||
unsigned int
|
||||
isc__task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag, isc_eventlist_t *events);
|
||||
isc_result_t
|
||||
isc__task_onshutdown(isc_task_t *task0, isc_taskaction_t action,
|
||||
void *arg);
|
||||
void
|
||||
isc__task_shutdown(isc_task_t *task0);
|
||||
void
|
||||
isc__task_destroy(isc_task_t **taskp);
|
||||
void
|
||||
isc__task_setname(isc_task_t *task0, const char *name, void *tag);
|
||||
const char *
|
||||
isc__task_getname(isc_task_t *task0);
|
||||
void *
|
||||
isc__task_gettag(isc_task_t *task0);
|
||||
void
|
||||
isc__task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t);
|
||||
void
|
||||
isc__task_getcurrenttimex(isc_task_t *task0, isc_time_t *t);
|
||||
isc_result_t
|
||||
isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
unsigned int default_quantum, isc_taskmgr_t **managerp);
|
||||
void
|
||||
isc__taskmgr_destroy(isc_taskmgr_t **managerp);
|
||||
void
|
||||
isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0);
|
||||
isc_result_t
|
||||
isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp);
|
||||
isc_result_t
|
||||
isc__task_beginexclusive(isc_task_t *task);
|
||||
void
|
||||
isc__task_endexclusive(isc_task_t *task0);
|
||||
void
|
||||
isc__task_setprivilege(isc_task_t *task0, bool priv);
|
||||
bool
|
||||
isc__task_privilege(isc_task_t *task0);
|
||||
void
|
||||
isc__taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode);
|
||||
isc_taskmgrmode_t
|
||||
isc__taskmgr_mode(isc_taskmgr_t *manager0);
|
||||
|
||||
static inline bool
|
||||
empty_readyq(isc__taskmgr_t *manager);
|
||||
|
||||
@@ -236,49 +183,6 @@ pop_readyq(isc__taskmgr_t *manager);
|
||||
static inline void
|
||||
push_readyq(isc__taskmgr_t *manager, isc__task_t *task);
|
||||
|
||||
static struct isc__taskmethods {
|
||||
isc_taskmethods_t methods;
|
||||
|
||||
/*%
|
||||
* The following are defined just for avoiding unused static functions.
|
||||
*/
|
||||
void *purgeevent, *unsendrange, *getname, *gettag,
|
||||
*getcurrenttime, *getcurrenttimex;
|
||||
} taskmethods = {
|
||||
{
|
||||
isc__task_attach,
|
||||
isc__task_detach,
|
||||
isc__task_destroy,
|
||||
isc__task_send,
|
||||
isc__task_sendanddetach,
|
||||
isc__task_unsend,
|
||||
isc__task_onshutdown,
|
||||
isc__task_shutdown,
|
||||
isc__task_setname,
|
||||
isc__task_purge,
|
||||
isc__task_purgerange,
|
||||
isc__task_beginexclusive,
|
||||
isc__task_endexclusive,
|
||||
isc__task_setprivilege,
|
||||
isc__task_privilege
|
||||
},
|
||||
(void *)isc_task_purgeevent,
|
||||
(void *)isc__task_unsendrange,
|
||||
(void *)isc__task_getname,
|
||||
(void *)isc__task_gettag,
|
||||
(void *)isc__task_getcurrenttime,
|
||||
(void *)isc__task_getcurrenttimex
|
||||
};
|
||||
|
||||
static isc_taskmgrmethods_t taskmgrmethods = {
|
||||
isc__taskmgr_destroy,
|
||||
isc__taskmgr_setmode,
|
||||
isc__taskmgr_mode,
|
||||
isc__task_create,
|
||||
isc_taskmgr_setexcltask,
|
||||
isc_taskmgr_excltask
|
||||
};
|
||||
|
||||
/***
|
||||
*** Tasks.
|
||||
***/
|
||||
@@ -315,7 +219,7 @@ task_finished(isc__task_t *task) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
isc_task_create(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
isc_task_t **taskp)
|
||||
{
|
||||
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
|
||||
@@ -367,7 +271,6 @@ isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
return (ISC_R_SHUTTINGDOWN);
|
||||
}
|
||||
|
||||
task->common.methods = (isc_taskmethods_t *)&taskmethods;
|
||||
task->common.magic = ISCAPI_TASK_MAGIC;
|
||||
task->common.impmagic = TASK_MAGIC;
|
||||
*taskp = (isc_task_t *)task;
|
||||
@@ -376,7 +279,7 @@ isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_attach(isc_task_t *source0, isc_task_t **targetp) {
|
||||
isc_task_attach(isc_task_t *source0, isc_task_t **targetp) {
|
||||
isc__task_t *source = (isc__task_t *)source0;
|
||||
|
||||
/*
|
||||
@@ -442,7 +345,7 @@ task_shutdown(isc__task_t *task) {
|
||||
static inline void
|
||||
task_ready(isc__task_t *task) {
|
||||
isc__taskmgr_t *manager = task->manager;
|
||||
bool has_privilege = isc__task_privilege((isc_task_t *) task);
|
||||
bool has_privilege = isc_task_privilege((isc_task_t *) task);
|
||||
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
REQUIRE(task->state == task_state_ready);
|
||||
@@ -486,7 +389,7 @@ task_detach(isc__task_t *task) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_detach(isc_task_t **taskp) {
|
||||
isc_task_detach(isc_task_t **taskp) {
|
||||
isc__task_t *task;
|
||||
bool was_idle;
|
||||
|
||||
@@ -543,7 +446,7 @@ task_send(isc__task_t *task, isc_event_t **eventp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_send(isc_task_t *task0, isc_event_t **eventp) {
|
||||
isc_task_send(isc_task_t *task0, isc_event_t **eventp) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
bool was_idle;
|
||||
|
||||
@@ -585,7 +488,7 @@ isc__task_send(isc_task_t *task0, isc_event_t **eventp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
|
||||
isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
|
||||
bool idle1, idle2;
|
||||
isc__task_t *task;
|
||||
|
||||
@@ -662,13 +565,14 @@ dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc__task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
|
||||
isc_task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag)
|
||||
{
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
unsigned int count;
|
||||
isc_eventlist_t events;
|
||||
isc_event_t *event, *next_event;
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
/*
|
||||
* Purge events from a task's event queue.
|
||||
@@ -695,16 +599,17 @@ isc__task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc__task_purge(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag)
|
||||
{
|
||||
/*
|
||||
* Purge events from a task's event queue.
|
||||
*/
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
XTRACE("isc_task_purge");
|
||||
|
||||
return (isc__task_purgerange(task, sender, type, type, tag));
|
||||
return (isc_task_purgerange(task, sender, type, type, tag));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -752,13 +657,14 @@ isc_task_purgeevent(isc_task_t *task0, isc_event_t *event) {
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc__task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
isc_task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag,
|
||||
isc_eventlist_t *events)
|
||||
{
|
||||
/*
|
||||
* Remove events from a task's event queue.
|
||||
*/
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
XTRACE("isc_task_unsendrange");
|
||||
|
||||
@@ -767,7 +673,7 @@ isc__task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc__task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag, isc_eventlist_t *events)
|
||||
{
|
||||
/*
|
||||
@@ -781,7 +687,7 @@ isc__task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__task_onshutdown(isc_task_t *task0, isc_taskaction_t action,
|
||||
isc_task_onshutdown(isc_task_t *task0, isc_taskaction_t action,
|
||||
void *arg)
|
||||
{
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
@@ -821,7 +727,7 @@ isc__task_onshutdown(isc_task_t *task0, isc_taskaction_t action,
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_shutdown(isc_task_t *task0) {
|
||||
isc_task_shutdown(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
bool was_idle;
|
||||
|
||||
@@ -840,7 +746,7 @@ isc__task_shutdown(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_destroy(isc_task_t **taskp) {
|
||||
isc_task_destroy(isc_task_t **taskp) {
|
||||
|
||||
/*
|
||||
* Destroy '*taskp'.
|
||||
@@ -853,7 +759,7 @@ isc__task_destroy(isc_task_t **taskp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_setname(isc_task_t *task0, const char *name, void *tag) {
|
||||
isc_task_setname(isc_task_t *task0, const char *name, void *tag) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
/*
|
||||
@@ -868,8 +774,9 @@ isc__task_setname(isc_task_t *task0, const char *name, void *tag) {
|
||||
UNLOCK(&task->lock);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
isc__task_getname(isc_task_t *task0) {
|
||||
isc_task_getname(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
REQUIRE(VALID_TASK(task));
|
||||
@@ -878,7 +785,7 @@ isc__task_getname(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void *
|
||||
isc__task_gettag(isc_task_t *task0) {
|
||||
isc_task_gettag(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
REQUIRE(VALID_TASK(task));
|
||||
@@ -887,7 +794,7 @@ isc__task_gettag(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
|
||||
isc_task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
REQUIRE(VALID_TASK(task));
|
||||
@@ -899,7 +806,7 @@ isc__task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_getcurrenttimex(isc_task_t *task0, isc_time_t *t) {
|
||||
isc_task_getcurrenttimex(isc_task_t *task0, isc_time_t *t) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
REQUIRE(VALID_TASK(task));
|
||||
@@ -1276,7 +1183,7 @@ manager_free(isc__taskmgr_t *manager) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
unsigned int default_quantum, isc_taskmgr_t **managerp)
|
||||
{
|
||||
isc_result_t result;
|
||||
@@ -1293,7 +1200,6 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
manager = isc_mem_get(mctx, sizeof(*manager));
|
||||
if (manager == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
manager->common.methods = &taskmgrmethods;
|
||||
manager->common.impmagic = TASK_MANAGER_MAGIC;
|
||||
manager->common.magic = ISCAPI_TASKMGR_MAGIC;
|
||||
manager->mode = isc_taskmgrmode_normal;
|
||||
@@ -1395,7 +1301,7 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
}
|
||||
|
||||
void
|
||||
isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
|
||||
isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
|
||||
isc__taskmgr_t *manager;
|
||||
isc__task_t *task;
|
||||
unsigned int i;
|
||||
@@ -1422,7 +1328,7 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
|
||||
*/
|
||||
LOCK(&manager->excl_lock);
|
||||
if (manager->excl != NULL)
|
||||
isc__task_detach((isc_task_t **) &manager->excl);
|
||||
isc_task_detach((isc_task_t **) &manager->excl);
|
||||
UNLOCK(&manager->excl_lock);
|
||||
|
||||
/*
|
||||
@@ -1479,7 +1385,7 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode) {
|
||||
isc_taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode) {
|
||||
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
|
||||
|
||||
LOCK(&manager->lock);
|
||||
@@ -1488,7 +1394,7 @@ isc__taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode) {
|
||||
}
|
||||
|
||||
isc_taskmgrmode_t
|
||||
isc__taskmgr_mode(isc_taskmgr_t *manager0) {
|
||||
isc_taskmgr_mode(isc_taskmgr_t *manager0) {
|
||||
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
|
||||
isc_taskmgrmode_t mode;
|
||||
LOCK(&manager->lock);
|
||||
@@ -1529,8 +1435,8 @@ isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
LOCK(&mgr->excl_lock);
|
||||
if (mgr->excl != NULL)
|
||||
isc__task_detach((isc_task_t **) &mgr->excl);
|
||||
isc__task_attach(task0, (isc_task_t **) &mgr->excl);
|
||||
isc_task_detach((isc_task_t **) &mgr->excl);
|
||||
isc_task_attach(task0, (isc_task_t **) &mgr->excl);
|
||||
UNLOCK(&mgr->excl_lock);
|
||||
}
|
||||
|
||||
@@ -1544,7 +1450,7 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
|
||||
|
||||
LOCK(&mgr->excl_lock);
|
||||
if (mgr->excl != NULL)
|
||||
isc__task_attach((isc_task_t *) mgr->excl, taskp);
|
||||
isc_task_attach((isc_task_t *) mgr->excl, taskp);
|
||||
else
|
||||
result = ISC_R_NOTFOUND;
|
||||
UNLOCK(&mgr->excl_lock);
|
||||
@@ -1553,9 +1459,10 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__task_beginexclusive(isc_task_t *task0) {
|
||||
isc_task_beginexclusive(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc__taskmgr_t *manager = task->manager;
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
REQUIRE(task->state == task_state_running);
|
||||
/*
|
||||
@@ -1577,10 +1484,11 @@ isc__task_beginexclusive(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_endexclusive(isc_task_t *task0) {
|
||||
isc_task_endexclusive(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc__taskmgr_t *manager = task->manager;
|
||||
|
||||
REQUIRE(VALID_TASK(task));
|
||||
REQUIRE(task->state == task_state_running);
|
||||
LOCK(&manager->lock);
|
||||
REQUIRE(manager->exclusive_requested);
|
||||
@@ -1590,7 +1498,8 @@ isc__task_endexclusive(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__task_setprivilege(isc_task_t *task0, bool priv) {
|
||||
isc_task_setprivilege(isc_task_t *task0, bool priv) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task0));
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc__taskmgr_t *manager = task->manager;
|
||||
bool oldpriv;
|
||||
@@ -1617,9 +1526,10 @@ isc__task_setprivilege(isc_task_t *task0, bool priv) {
|
||||
}
|
||||
|
||||
bool
|
||||
isc__task_privilege(isc_task_t *task0) {
|
||||
isc_task_privilege(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
bool priv;
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
LOCK(&task->lock);
|
||||
priv = (task->flags & TASK_F_PRIVILEGED);
|
||||
@@ -1627,11 +1537,6 @@ isc__task_privilege(isc_task_t *task0) {
|
||||
return (priv);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__task_register(void) {
|
||||
return (isc_task_register(isc__taskmgr_create));
|
||||
}
|
||||
|
||||
bool
|
||||
isc_task_exiting(isc_task_t *t) {
|
||||
isc__task_t *task = (isc__task_t *)t;
|
||||
@@ -1837,31 +1742,6 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, json_object *tasks) {
|
||||
#endif
|
||||
|
||||
|
||||
static isc_mutex_t createlock;
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_taskmgrcreatefunc_t taskmgr_createfunc = NULL;
|
||||
|
||||
static void
|
||||
initialize(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_task_register(isc_taskmgrcreatefunc_t createfunc) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&createlock);
|
||||
if (taskmgr_createfunc == NULL)
|
||||
taskmgr_createfunc = createfunc;
|
||||
else
|
||||
result = ISC_R_EXISTS;
|
||||
UNLOCK(&createlock);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
unsigned int workers, unsigned int default_quantum,
|
||||
@@ -1869,189 +1749,12 @@ isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
LOCK(&createlock);
|
||||
|
||||
REQUIRE(taskmgr_createfunc != NULL);
|
||||
result = (*taskmgr_createfunc)(mctx, workers, default_quantum,
|
||||
result = isc_taskmgr_create(mctx, workers, default_quantum,
|
||||
managerp);
|
||||
|
||||
UNLOCK(&createlock);
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
isc_appctx_settaskmgr(actx, *managerp);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
unsigned int default_quantum, isc_taskmgr_t **managerp)
|
||||
{
|
||||
return (isc__taskmgr_create(mctx, workers,
|
||||
default_quantum, managerp));
|
||||
}
|
||||
|
||||
void
|
||||
isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
|
||||
REQUIRE(managerp != NULL && ISCAPI_TASKMGR_VALID(*managerp));
|
||||
|
||||
isc__taskmgr_destroy(managerp);
|
||||
|
||||
ENSURE(*managerp == NULL);
|
||||
}
|
||||
|
||||
void
|
||||
isc_taskmgr_setmode(isc_taskmgr_t *manager, isc_taskmgrmode_t mode) {
|
||||
REQUIRE(ISCAPI_TASKMGR_VALID(manager));
|
||||
|
||||
isc__taskmgr_setmode(manager, mode);
|
||||
}
|
||||
|
||||
isc_taskmgrmode_t
|
||||
isc_taskmgr_mode(isc_taskmgr_t *manager) {
|
||||
REQUIRE(ISCAPI_TASKMGR_VALID(manager));
|
||||
|
||||
return (isc__taskmgr_mode(manager));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
|
||||
isc_task_t **taskp)
|
||||
{
|
||||
REQUIRE(ISCAPI_TASKMGR_VALID(manager));
|
||||
REQUIRE(taskp != NULL && *taskp == NULL);
|
||||
|
||||
return (isc__task_create(manager, quantum, taskp));
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_attach(isc_task_t *source, isc_task_t **targetp) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(source));
|
||||
REQUIRE(targetp != NULL && *targetp == NULL);
|
||||
|
||||
isc__task_attach(source, targetp);
|
||||
|
||||
ENSURE(*targetp == source);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_detach(isc_task_t **taskp) {
|
||||
REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp));
|
||||
|
||||
isc__task_detach(taskp);
|
||||
|
||||
ENSURE(*taskp == NULL);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_send(isc_task_t *task, isc_event_t **eventp) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
REQUIRE(eventp != NULL && *eventp != NULL);
|
||||
|
||||
isc__task_send(task, eventp);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
|
||||
REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp));
|
||||
REQUIRE(eventp != NULL && *eventp != NULL);
|
||||
|
||||
isc__task_sendanddetach(taskp, eventp);
|
||||
|
||||
ENSURE(*taskp == NULL);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag, isc_eventlist_t *events)
|
||||
{
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
return (isc__task_unsend(task, sender, type, tag, events));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_task_onshutdown(isc_task_t *task, isc_taskaction_t action, void *arg)
|
||||
{
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
return (isc__task_onshutdown(task, action, arg));
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_shutdown(isc_task_t *task) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
isc__task_shutdown(task);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_destroy(isc_task_t **taskp) {
|
||||
isc__task_destroy(taskp);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_setname(isc_task_t *task, const char *name, void *tag) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
isc__task_setname(task, name, tag);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type, void *tag)
|
||||
{
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
return (isc__task_purge(task, sender, type, tag));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_task_beginexclusive(isc_task_t *task) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
return (isc__task_beginexclusive(task));
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_endexclusive(isc_task_t *task) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
isc__task_endexclusive(task);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_setprivilege(isc_task_t *task, bool priv) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
isc__task_setprivilege(task, priv);
|
||||
}
|
||||
|
||||
bool
|
||||
isc_task_privilege(isc_task_t *task) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
return (isc__task_privilege(task));
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_getcurrenttime(isc_task_t *task, isc_stdtime_t *t) {
|
||||
isc__task_getcurrenttime(task, t);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_getcurrenttimex(isc_task_t *task, isc_time_t *t) {
|
||||
isc__task_getcurrenttimex(task, t);
|
||||
}
|
||||
|
||||
/*%
|
||||
* This is necessary for libisc's internal timer implementation. Other
|
||||
* implementation might skip implementing this.
|
||||
*/
|
||||
unsigned int
|
||||
isc_task_purgerange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag)
|
||||
{
|
||||
REQUIRE(ISCAPI_TASK_VALID(task));
|
||||
|
||||
return (isc__task_purgerange(task, sender, first, last, tag));
|
||||
}
|
||||
|
Reference in New Issue
Block a user