* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
* \brief A task pool is a mechanism for sharing a small number of tasks
* among a large number of objects such that each object is
* assigned a unique task, but each task may be shared by several
* Task pools are used to let objects that can exist in large
* numbers (e.g., zones) use tasks for synchronization without
* the memory overhead and unfair scheduling competition that
* could result from creating a separate task for each object.
typedef struct isc_taskpool isc_taskpool_t;
isc_taskpool_create(isc_taskmgr_t *tmgr, isc_mem_t *mctx,
unsigned int ntasks, unsigned int quantum,
* Create a task pool of "ntasks" tasks, each with quantum
*\li 'tmgr' is a valid task manager.
*\li 'mctx' is a valid memory context.
*\li poolp != NULL && *poolp == NULL
*\li On success, '*taskp' points to the new task pool.
isc_taskpool_gettask(isc_taskpool_t *pool, isc_task_t **targetp);
* Attach to a task from the pool. Currently the next task is chosen
* from the pool at random. (This may be changed in the future to
* something that guaratees balance.)
isc_taskpool_size(isc_taskpool_t *pool);
* Returns the number of tasks in the task pool 'pool'.
isc_taskpool_expand(isc_taskpool_t **sourcep, unsigned int size,
isc_taskpool_t **targetp);
* If 'size' is larger than the number of tasks in the pool pointed to by
* 'sourcep', then a new taskpool of size 'size' is allocated, the existing
* tasks from are moved into it, additional tasks are created to bring the
* total number up to 'size', and the resulting pool is attached to
* If 'size' is less than or equal to the tasks in pool 'source', then
* 'sourcep' is attached to 'targetp' without any other action being taken.
* In either case, 'sourcep' is detached.
* \li 'sourcep' is not NULL and '*source' is not NULL
* \li 'targetp' is not NULL and '*source' is NULL
* \li On success, '*targetp' points to a valid task pool.
* \li On success, '*sourcep' points to NULL.
isc_taskpool_destroy(isc_taskpool_t **poolp);
* Destroy a task pool. The tasks in the pool are detached but not
* \li '*poolp' is a valid task pool.
isc_taskpool_setprivilege(isc_taskpool_t *pool, bool priv);
* Set the privilege flag on all tasks in 'pool' to 'priv'. If 'priv' is
* true, then when the task manager is set into privileged mode, only
* tasks wihin this pool will be able to execute. (Note: It is important
* to turn the pool tasks' privilege back off before the last task finishes
* \li 'pool' is a valid task pool.
#endif /* ISC_TASKPOOL_H */