WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

Caching pool is one sample implementation of pool factory where the factory can reuse memory to create a pool. Application defines what the maximum memory the factory can hold, and when a pool is released the factory decides whether to destroy the pool or to keep it for future use. If the total amount of memory in the internal cache is still within the limit, the factory will keep the pool in the internal cache, otherwise the pool will be destroyed, thus releasing the memory back to the system. More...

Data Structures

struct  pj_caching_pool
 

Macros

#define PJ_CACHING_POOL_ARRAY_SIZE   16
 

Functions

void pj_caching_pool_init (pj_caching_pool *ch_pool, const pj_pool_factory_policy *policy, pj_size_t max_capacity)
 
void pj_caching_pool_destroy (pj_caching_pool *ch_pool)
 

Detailed Description

Caching pool is one sample implementation of pool factory where the factory can reuse memory to create a pool. Application defines what the maximum memory the factory can hold, and when a pool is released the factory decides whether to destroy the pool or to keep it for future use. If the total amount of memory in the internal cache is still within the limit, the factory will keep the pool in the internal cache, otherwise the pool will be destroyed, thus releasing the memory back to the system.

// PJ_POOL_FACTORY

Macro Definition Documentation

◆ PJ_CACHING_POOL_ARRAY_SIZE

#define PJ_CACHING_POOL_ARRAY_SIZE   16

Number of unique sizes, to be used as index to the free list. Each pool in the free list is organized by it's size.

Function Documentation

◆ pj_caching_pool_destroy()

void pj_caching_pool_destroy ( pj_caching_pool ch_pool)

Destroy caching pool, and release all the pools in the recycling list.

Parameters
ch_poolThe caching pool.

◆ pj_caching_pool_init()

void pj_caching_pool_init ( pj_caching_pool ch_pool,
const pj_pool_factory_policy policy,
pj_size_t  max_capacity 
)

Initialize caching pool.

Parameters
ch_poolThe caching pool factory to be initialized.
policyPool factory policy.
max_capacityThe total capacity to be retained in the cache. When the pool is returned to the cache, it will be kept in recycling list if the total capacity of pools in this list plus the capacity of the pool is still below this value.

 


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