task_api.c revision 7a54dadeb565d746ef8b3fc77dc76455d836dd30
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * purpose with or without fee is hereby granted, provided that the above
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * copyright notice and this permission notice appear in all copies.
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * PERFORMANCE OF THIS SOFTWARE.
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryver/* $Id: task_api.c,v 1.6 2010/12/22 05:19:02 marka Exp $ */
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryverstatic isc_taskmgrcreatefunc_t taskmgr_createfunc = NULL;
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrewsisc_task_register(isc_taskmgrcreatefunc_t createfunc) {
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryver RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryverisc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryver unsigned int workers, unsigned int default_quantum,
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryver result = (*taskmgr_createfunc)(mctx, workers, default_quantum,
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrewsisc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews unsigned int default_quantum, isc_taskmgr_t **managerp)
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryver result = (*taskmgr_createfunc)(mctx, workers, default_quantum,
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryverisc_taskmgr_destroy(isc_taskmgr_t **managerp) {
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryver REQUIRE(managerp != NULL && ISCAPI_TASKMGR_VALID(*managerp));
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryverisc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
9fee08f655527a5dd849b171daeeee1dbbccca76Vernon Schryver return (manager->methods->taskcreate(manager, quantum, taskp));
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrewsisc_task_attach(isc_task_t *source, isc_task_t **targetp) {