pool.c File Reference

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

Go to the source code of this file.

Data Structures

struct  isc_pool

Functions

static isc_result_t alloc_pool (isc_mem_t *mctx, unsigned int count, isc_pool_t **poolp)
isc_result_t isc_pool_create (isc_mem_t *mctx, unsigned int count, isc_pooldeallocator_t release, isc_poolinitializer_t init, void *initarg, isc_pool_t **poolp)
 Create a pool of "count" object pointers. If 'free' is not NULL, it points to a function that will detach the objects. 'init' points to a function that will initialize the arguments, and 'arg' to an argument to be passed into that function (for example, a relevant manager or context object).
void * isc_pool_get (isc_pool_t *pool)
 Returns a pointer to an object from the pool. Currently the object is chosen from the pool at random. (This may be changed in the future to something that guaratees balance.).
int isc_pool_count (isc_pool_t *pool)
 Returns the number of objcts in the pool 'pool'.
isc_result_t isc_pool_expand (isc_pool_t **sourcep, unsigned int count, isc_pool_t **targetp)
 If 'size' is larger than the number of objects in the pool pointed to by 'sourcep', then a new pool of size 'count' is allocated, the existing objects are copied into it, additional ones created to bring the total number up to 'count', and the resulting pool is attached to 'targetp'.
void isc_pool_destroy (isc_pool_t **poolp)
 Destroy a task pool. The tasks in the pool are detached but not shut down.


Detailed Description

Definition in file pool.c.


Function Documentation

static isc_result_t alloc_pool ( isc_mem_t mctx,
unsigned int  count,
isc_pool_t **  poolp 
) [static]

Definition at line 48 of file pool.c.

References isc_pool::count, isc_pool::free, isc_pool::init, isc_pool::initarg, isc_mem_attach(), isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_pool::mctx, and isc_pool::pool.

Referenced by isc_pool_create(), isc_pool_expand(), isc_taskpool_create(), and isc_taskpool_expand().

isc_result_t isc_pool_create ( isc_mem_t mctx,
unsigned int  count,
isc_pooldeallocator_t  free,
isc_poolinitializer_t  init,
void *  initarg,
isc_pool_t **  poolp 
)

Create a pool of "count" object pointers. If 'free' is not NULL, it points to a function that will detach the objects. 'init' points to a function that will initialize the arguments, and 'arg' to an argument to be passed into that function (for example, a relevant manager or context object).

Requires:

Ensures:

Returns:

Definition at line 72 of file pool.c.

References alloc_pool(), isc_pool::free, isc_pool::init, isc_pool::initarg, INSIST, isc_pool_destroy(), ISC_R_SUCCESS, and isc_pool::pool.

Referenced by ATF_TC_BODY(), and dns_zonemgr_setsize().

void* isc_pool_get ( isc_pool_t pool  ) 

Returns a pointer to an object from the pool. Currently the object is chosen from the pool at random. (This may be changed in the future to something that guaratees balance.).

Definition at line 106 of file pool.c.

References isc_pool::count, isc_random_get(), and isc_pool::pool.

Referenced by ATF_TC_BODY(), and dns_zonemgr_createzone().

int isc_pool_count ( isc_pool_t pool  ) 

Returns the number of objcts in the pool 'pool'.

Definition at line 113 of file pool.c.

References isc_pool::count, and REQUIRE.

Referenced by ATF_TC_BODY().

isc_result_t isc_pool_expand ( isc_pool_t **  sourcep,
unsigned int  count,
isc_pool_t **  targetp 
)

If 'size' is larger than the number of objects in the pool pointed to by 'sourcep', then a new pool of size 'count' is allocated, the existing objects are copied into it, additional ones created to bring the total number up to 'count', and the resulting pool is attached to 'targetp'.

If 'count' is less than or equal to the number of objects in '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 119 of file pool.c.

References alloc_pool(), isc_pool::count, isc_pool::free, isc_pool::init, isc_pool::initarg, isc_pool_destroy(), ISC_R_SUCCESS, isc_pool::mctx, isc_pool::pool, and REQUIRE.

Referenced by ATF_TC_BODY(), and dns_zonemgr_setsize().

void isc_pool_destroy ( isc_pool_t **  poolp  ) 

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

Requires:

Definition at line 167 of file pool.c.

References isc_pool::count, isc_pool::free, isc_mem_put, isc_mem_putanddetach, isc_pool::mctx, and isc_pool::pool.

Referenced by ATF_TC_BODY(), dns_zonemgr_shutdown(), isc_pool_create(), and isc_pool_expand().


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