taskpool.c File Reference

#include <config.h>
#include <isc/mem.h>
#include <isc/random.h>
#include <isc/taskpool.h>
#include <isc/util.h>

Go to the source code of this file.

Data Structures

struct  isc_taskpool

Functions

static isc_result_t alloc_pool (isc_taskmgr_t *tmgr, isc_mem_t *mctx, unsigned int ntasks, unsigned int quantum, isc_taskpool_t **poolp)
isc_result_t isc_taskpool_create (isc_taskmgr_t *tmgr, isc_mem_t *mctx, unsigned int ntasks, unsigned int quantum, isc_taskpool_t **poolp)
 Create a task pool of "ntasks" tasks, each with quantum "quantum".
void 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.).
int isc_taskpool_size (isc_taskpool_t *pool)
 Returns the number of tasks in the task pool 'pool'.
isc_result_t 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 'targetp'.
void isc_taskpool_destroy (isc_taskpool_t **poolp)
 Destroy a task pool. The tasks in the pool are detached but not shut down.
void isc_taskpool_setprivilege (isc_taskpool_t *pool, isc_boolean_t 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 executing.).


Detailed Description

Definition in file taskpool.c.


Function Documentation

static isc_result_t alloc_pool ( isc_taskmgr_t tmgr,
isc_mem_t mctx,
unsigned int  ntasks,
unsigned int  quantum,
isc_taskpool_t **  poolp 
) [static]

Definition at line 46 of file taskpool.c.

References isc_mem_attach(), isc_mem_get, isc_mem_putanddetach, ISC_R_NOMEMORY, ISC_R_SUCCESS, and return().

isc_result_t isc_taskpool_create ( isc_taskmgr_t tmgr,
isc_mem_t mctx,
unsigned int  ntasks,
unsigned int  quantum,
isc_taskpool_t **  poolp 
)

Create a task pool of "ntasks" tasks, each with quantum "quantum".

Requires:

Ensures:

Returns:

Definition at line 74 of file taskpool.c.

References alloc_pool(), INSIST, ISC_R_SUCCESS, isc_task_create(), isc_task_setname(), and isc_taskpool_destroy().

Referenced by ATF_TC_BODY(), and dns_zonemgr_setsize().

void 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.).

Definition at line 104 of file taskpool.c.

References isc_random_get(), and isc_task_attach().

Referenced by ATF_TC_BODY(), and dns_zonemgr_managezone().

int isc_taskpool_size ( isc_taskpool_t pool  ) 

Returns the number of tasks in the task pool 'pool'.

Definition at line 111 of file taskpool.c.

References REQUIRE.

Referenced by ATF_TC_BODY().

isc_result_t 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 'targetp'.

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.

Requires:

Ensures:

Returns:

Definition at line 117 of file taskpool.c.

References alloc_pool(), ISC_R_SUCCESS, isc_task_create(), isc_task_setname(), isc_taskpool_destroy(), and REQUIRE.

Referenced by ATF_TC_BODY(), and dns_zonemgr_setsize().

void isc_taskpool_destroy ( isc_taskpool_t **  poolp  ) 

Destroy a task pool. The tasks in the pool are detached but not shut down.

Requires:

Definition at line 164 of file taskpool.c.

References isc_mem_put, isc_mem_putanddetach, and isc_task_detach().

Referenced by ATF_TC_BODY(), dns_zonemgr_shutdown(), isc_taskpool_create(), and isc_taskpool_expand().

void isc_taskpool_setprivilege ( isc_taskpool_t pool,
isc_boolean_t  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 executing.).

Requires:

Definition at line 178 of file taskpool.c.

References isc_task_setprivilege(), and REQUIRE.

Referenced by ATF_TC_BODY(), and dns_zonemgr_setsize().


Generated on Tue Apr 28 17:41:18 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha