BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

pj_pool_factory Struct Reference

#include <pool.h>

Data Fields

pj_pool_factory_policy policy
 
pj_pool_t *(* create_pool )(pj_pool_factory *factory, const char *name, pj_size_t initial_size, pj_size_t increment_size, pj_pool_callback *callback)
 
void(* release_pool )(pj_pool_factory *factory, pj_pool_t *pool)
 
void(* dump_status )(pj_pool_factory *factory, pj_bool_t detail)
 
pj_bool_t(* on_block_alloc )(pj_pool_factory *factory, pj_size_t size)
 
void(* on_block_free )(pj_pool_factory *factory, pj_size_t size)
 
int dummy
 

Detailed Description

This structure contains the declaration for pool factory interface.

Forward declaration for memory pool factory.

Field Documentation

◆ create_pool

pj_pool_t *(* pj_pool_factory::create_pool) (pj_pool_factory *factory, const char *name, pj_size_t initial_size, pj_size_t increment_size, pj_pool_callback *callback)

Create a new pool from the pool factory.

Parameters
factoryThe pool factory.
namethe name to be assigned to the pool. The name should not be longer than PJ_MAX_OBJ_NAME (32 chars), or otherwise it will be truncated.
initial_sizethe size of initial memory blocks taken by the pool. Note that the pool will take 68+20 bytes for administrative area from this block.
increment_sizethe size of each additional blocks to be allocated when the pool is running out of memory. If user requests memory which is larger than this size, then an error occurs. Note that each time a pool allocates additional block, it needs 20 bytes (equal to sizeof(pj_pool_block)) to store some administrative info.
callbackCllback to be called when error occurs in the pool. Note that when an error occurs during pool creation, the callback itself is not called. Instead, NULL will be returned.
Returns
the memory pool, or NULL.

◆ dump_status

void(* pj_pool_factory::dump_status) (pj_pool_factory *factory, pj_bool_t detail)

Dump pool status to log.

Parameters
factoryThe pool factory.

Referenced by pj_pool_factory_dump().

◆ on_block_alloc

pj_bool_t(* pj_pool_factory::on_block_alloc) (pj_pool_factory *factory, pj_size_t size)

This is optional callback to be called by allocation policy when it allocates a new memory block. The factory may use this callback for example to keep track of the total number of memory blocks currently allocated by applications.

Parameters
factoryThe pool factory.
sizeSize requested by application.
Returns
MUST return PJ_TRUE, otherwise the block allocation is cancelled.

◆ on_block_free

void(* pj_pool_factory::on_block_free) (pj_pool_factory *factory, pj_size_t size)

This is optional callback to be called by allocation policy when it frees memory block. The factory may use this callback for example to keep track of the total number of memory blocks currently allocated by applications.

Parameters
factoryThe pool factory.
sizeSize freed.

◆ policy

pj_pool_factory_policy pj_pool_factory::policy

Memory pool policy.

◆ release_pool

void(* pj_pool_factory::release_pool) (pj_pool_factory *factory, pj_pool_t *pool)

Release the pool to the pool factory.

Parameters
factoryThe pool factory.
poolThe pool to be released.

The documentation for this struct was generated from the following files:

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.