task_api.c revision 9eae5f2a7a189353bd4fcbb939c2b61094b3bfe9
3398334b3acda24b086957286288ca9852662b12Automatic Updater * Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
fda0ab6a96a7edb1acbde0c77ead0542979b0f24Bob Halley/* $Id: task_api.c,v 1.3 2009/09/01 03:43:27 jinmei Exp $ */
440be4c866f6935ac069db79a414304507a664c2Michael Graffstatic isc_taskmgrcreatefunc_t taskmgr_createfunc = NULL;
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleyisc_task_register(isc_taskmgrcreatefunc_t createfunc) {
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinisc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein unsigned int workers, unsigned int default_quantum,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein result = (*taskmgr_createfunc)(mctx, workers, default_quantum,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinisc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein unsigned int default_quantum, isc_taskmgr_t **managerp)
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein result = (*taskmgr_createfunc)(mctx, workers, default_quantum,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein REQUIRE(managerp != NULL && ISCAPI_TASKMGR_VALID(*managerp));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsisc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
5804af97ab0875fafd233f486aa1c1899ed5c00aBob Halley return (manager->methods->taskcreate(manager, quantum, taskp));
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleyisc_task_attach(isc_task_t *source, isc_task_t **targetp) {
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp));
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleyisc_task_send(isc_task_t *task, isc_event_t **eventp) {
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleyisc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp));
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleyisc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley return (task->methods->unsend(task, sender, type, tag, events));
9cd6d409b78a6f833b681c13a68fbdc7c024fe66David Lawrenceisc_task_onshutdown(isc_task_t *task, isc_taskaction_t action, const void *arg)
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley return (task->methods->onshutdown(task, action, arg));
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleyisc_task_setname(isc_task_t *task, const char *name, void *tag) {
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleyisc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type, void *tag)
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley return (task->methods->purgeevents(task, sender, type, tag));
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley * This is necessary for libisc's internal timer implementation. Other
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley * implementation might skip implementing this.
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleyisc_task_purgerange(isc_task_t *task, void *sender, isc_eventtype_t first,
5804af97ab0875fafd233f486aa1c1899ed5c00aBob Halley return (task->methods->purgerange(task, sender, first, last, tag));