|
Packit |
857059 |
/* BEGIN_ICS_COPYRIGHT3 ****************************************
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Copyright (c) 2015, Intel Corporation
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Redistribution and use in source and binary forms, with or without
|
|
Packit |
857059 |
modification, are permitted provided that the following conditions are met:
|
|
Packit |
857059 |
|
|
Packit |
857059 |
* Redistributions of source code must retain the above copyright notice,
|
|
Packit |
857059 |
this list of conditions and the following disclaimer.
|
|
Packit |
857059 |
* Redistributions in binary form must reproduce the above copyright
|
|
Packit |
857059 |
notice, this list of conditions and the following disclaimer in the
|
|
Packit |
857059 |
documentation and/or other materials provided with the distribution.
|
|
Packit |
857059 |
* Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
857059 |
may be used to endorse or promote products derived from this software
|
|
Packit |
857059 |
without specific prior written permission.
|
|
Packit |
857059 |
|
|
Packit |
857059 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
857059 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
857059 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
857059 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
Packit |
857059 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
857059 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
857059 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Packit |
857059 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Packit |
857059 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
857059 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
857059 |
|
|
Packit |
857059 |
** END_ICS_COPYRIGHT3 ****************************************/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* [ICS VERSION STRING: unknown] */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifndef _IBA_PUBLIC_IGROWPOOL_H_
|
|
Packit |
857059 |
#define _IBA_PUBLIC_IGROWPOOL_H_
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#include "iba/public/datatypes.h"
|
|
Packit |
857059 |
#include "iba/public/iobjmgr.h"
|
|
Packit |
857059 |
#include "iba/public/ilist.h"
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifdef __cplusplus
|
|
Packit |
857059 |
extern "C" {
|
|
Packit |
857059 |
#endif
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
****************************************************************************
|
|
Packit |
857059 |
*********** **********
|
|
Packit |
857059 |
*********** DECLARATION OF QUICK COMPOSITE POOL **********
|
|
Packit |
857059 |
*********** **********
|
|
Packit |
857059 |
****************************************************************************
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef enum _POOL_STATE
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
PoolReset,
|
|
Packit |
857059 |
PoolInitError,
|
|
Packit |
857059 |
PoolReady
|
|
Packit |
857059 |
|
|
Packit |
857059 |
} POOL_STATE;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Quick composite pool callback
|
|
Packit |
857059 |
* function types.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef LIST_ITEM* (*QCPOOL_CTOR_FUNC)(
|
|
Packit |
857059 |
IN void** const pCompArray,
|
|
Packit |
857059 |
IN uint32 NumComponents,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef FSTATUS (*QCPOOL_INIT_FUNC)(
|
|
Packit |
857059 |
IN LIST_ITEM* const pListItem,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef void (*QCPOOL_DTOR_FUNC)(
|
|
Packit |
857059 |
IN LIST_ITEM* const pListItem,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Quick composite pool structure.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef struct _QCOMP_POOL
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
/* These fields are private and should NOt be directly accessed */
|
|
Packit |
857059 |
/* Number of components that make up a composite object. */
|
|
Packit |
857059 |
uint32 m_NumComponents;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Array of sizes for components that make up a user object. */
|
|
Packit |
857059 |
uint32 *m_ComponentSizes;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Array of pointers to components, used for constructor callback. */
|
|
Packit |
857059 |
void **m_pComponents;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Number of objects in the pool */
|
|
Packit |
857059 |
uint32 m_NumObjects;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Number of objects to auto-grow */
|
|
Packit |
857059 |
uint32 m_GrowSize;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Pointer to object constructor */
|
|
Packit |
857059 |
QCPOOL_CTOR_FUNC m_pfnCtor;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Pointer to object initializer */
|
|
Packit |
857059 |
QCPOOL_INIT_FUNC m_pfnInit;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Pointer to object destructor */
|
|
Packit |
857059 |
QCPOOL_DTOR_FUNC m_pfnDtor;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Context to pass to callback functions. */
|
|
Packit |
857059 |
void *m_Context;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Stack of available objects */
|
|
Packit |
857059 |
QUICK_LIST m_FreeList;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Object manager holds allocations */
|
|
Packit |
857059 |
OBJECT_MGR m_ObjMgr;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
POOL_STATE m_State;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
} QCOMP_POOL;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Quick composite pool access methods.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Initialize the state of a quick composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
QCompPoolInitState(
|
|
Packit |
857059 |
IN QCOMP_POOL* const pPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Initialize a quick composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
FSTATUS
|
|
Packit |
857059 |
QCompPoolInit(
|
|
Packit |
857059 |
IN QCOMP_POOL* const pPool,
|
|
Packit |
857059 |
IN const uint32 MinCount,
|
|
Packit |
857059 |
IN const uint32* const ComponentSizes,
|
|
Packit |
857059 |
IN const uint32 NumComponents,
|
|
Packit |
857059 |
IN const uint32 GrowSize,
|
|
Packit |
857059 |
IN QCPOOL_CTOR_FUNC pfnConstructor,
|
|
Packit |
857059 |
IN QCPOOL_INIT_FUNC pfnInitializer OPTIONAL,
|
|
Packit |
857059 |
IN QCPOOL_DTOR_FUNC pfnDestructor OPTIONAL,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Destroy a quick composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
QCompPoolDestroy(
|
|
Packit |
857059 |
IN QCOMP_POOL* const pPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Returns the number of objects available in a quick composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline uint32
|
|
Packit |
857059 |
QCompPoolCount(
|
|
Packit |
857059 |
IN QCOMP_POOL* const pPool )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pPool );
|
|
Packit |
857059 |
return( QListCount( &pPool->m_FreeList ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Get an object from a quick composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
LIST_ITEM*
|
|
Packit |
857059 |
QCompPoolGet(
|
|
Packit |
857059 |
IN QCOMP_POOL* const pPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Puts an object back in a quick composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline void
|
|
Packit |
857059 |
QCompPoolPut(
|
|
Packit |
857059 |
IN QCOMP_POOL* const pPool,
|
|
Packit |
857059 |
IN LIST_ITEM* const pListItem )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
/* return this lil' doggy to the pool */
|
|
Packit |
857059 |
QListInsertHead( &pPool->m_FreeList, pListItem );
|
|
Packit |
857059 |
/* check for funny-business */
|
|
Packit |
857059 |
ASSERT( QCompPoolCount(pPool) <= pPool->m_NumObjects );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Grows a quick composite pool by the specified number of objects.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
FSTATUS
|
|
Packit |
857059 |
QCompPoolGrow(
|
|
Packit |
857059 |
IN QCOMP_POOL* const pPool,
|
|
Packit |
857059 |
IN uint32 ObjCount );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
****************************************************************************
|
|
Packit |
857059 |
*********** **********
|
|
Packit |
857059 |
*********** DECLARATION OF QUICK GROW POOL **********
|
|
Packit |
857059 |
*********** **********
|
|
Packit |
857059 |
****************************************************************************
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Quick grow pool callback function types.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef LIST_ITEM* (*QGPOOL_CTOR_FUNC)(
|
|
Packit |
857059 |
IN void* const pObject,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef FSTATUS (*QGPOOL_INIT_FUNC)(
|
|
Packit |
857059 |
IN LIST_ITEM* const pListItem,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef void (*QGPOOL_DTOR_FUNC)(
|
|
Packit |
857059 |
IN LIST_ITEM* const pListItem,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Grow pool structure.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef struct _QGROW_POOL
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
/* These fields are private and should NOT be directly accessed */
|
|
Packit |
857059 |
QCOMP_POOL m_QCPool;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
QGPOOL_CTOR_FUNC m_pfnCtor;
|
|
Packit |
857059 |
QGPOOL_INIT_FUNC m_pfnInit;
|
|
Packit |
857059 |
QGPOOL_DTOR_FUNC m_pfnDtor;
|
|
Packit |
857059 |
void *m_Context;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
} QGROW_POOL;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Quick grow pool access methods.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Initializes the state of a quick grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
QGrowPoolInitState(
|
|
Packit |
857059 |
IN QGROW_POOL* const pPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Initializes a quick grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
FSTATUS
|
|
Packit |
857059 |
QGrowPoolInit(
|
|
Packit |
857059 |
IN QGROW_POOL* const pPool,
|
|
Packit |
857059 |
IN const uint32 MinCount,
|
|
Packit |
857059 |
IN const uint32 ObjectSize,
|
|
Packit |
857059 |
IN const uint32 GrowSize,
|
|
Packit |
857059 |
IN QGPOOL_CTOR_FUNC pfnConstructor OPTIONAL,
|
|
Packit |
857059 |
IN QGPOOL_INIT_FUNC pfnInitializer OPTIONAL,
|
|
Packit |
857059 |
IN QGPOOL_DTOR_FUNC pnfDestructor OPTIONAL,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Destroy a quick grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
QGrowPoolDestroy(
|
|
Packit |
857059 |
IN QGROW_POOL* const pPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Gets an object from a quick grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline LIST_ITEM*
|
|
Packit |
857059 |
QGrowPoolGet(
|
|
Packit |
857059 |
IN QGROW_POOL* const pPool )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pPool );
|
|
Packit |
857059 |
return( QCompPoolGet( &pPool->m_QCPool ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Puts an object back in the pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline void
|
|
Packit |
857059 |
QGrowPoolPut(
|
|
Packit |
857059 |
IN QGROW_POOL* const pPool,
|
|
Packit |
857059 |
LIST_ITEM* const pListItem )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pPool );
|
|
Packit |
857059 |
QCompPoolPut( &pPool->m_QCPool, pListItem );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Grows a quick grow pool by the specified number of objects.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline FSTATUS
|
|
Packit |
857059 |
QGrowPoolGrow(
|
|
Packit |
857059 |
IN QGROW_POOL* const pPool,
|
|
Packit |
857059 |
IN const uint32 ObjCount )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pPool );
|
|
Packit |
857059 |
return( QCompPoolGrow( &pPool->m_QCPool, ObjCount ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Returns the number of objects available in a quick grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline uint32
|
|
Packit |
857059 |
QGrowPoolCount(
|
|
Packit |
857059 |
IN QGROW_POOL* const pPool )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pPool );
|
|
Packit |
857059 |
return( QCompPoolCount( &pPool->m_QCPool ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
****************************************************************************
|
|
Packit |
857059 |
*********** **********
|
|
Packit |
857059 |
*********** DECLARATION OF COMPOSITE POOL **********
|
|
Packit |
857059 |
*********** **********
|
|
Packit |
857059 |
****************************************************************************
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Composite pool callback function types.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef void (*CPOOL_CTOR_FUNC)(
|
|
Packit |
857059 |
IN void** const pCompArray,
|
|
Packit |
857059 |
IN uint32 NumComponents,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef FSTATUS (*CPOOL_INIT_FUNC)(
|
|
Packit |
857059 |
IN void* const pObject,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef void (*CPOOL_DTOR_FUNC)(
|
|
Packit |
857059 |
IN void* const pObject,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Composite pool structure.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef struct _COMP_POOL
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
/* These fields are private and should NOT be directly accessed */
|
|
Packit |
857059 |
QCOMP_POOL m_QCPool;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Callback pointers. */
|
|
Packit |
857059 |
CPOOL_CTOR_FUNC m_pfnCtor;
|
|
Packit |
857059 |
CPOOL_INIT_FUNC m_pfnInit;
|
|
Packit |
857059 |
CPOOL_DTOR_FUNC m_pfnDtor;
|
|
Packit |
857059 |
/* Context to pass to callback functions. */
|
|
Packit |
857059 |
void *m_Context;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
} COMP_POOL;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Composite pool access methods.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Initializes the state of a composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
CompPoolInitState(
|
|
Packit |
857059 |
IN COMP_POOL* const pCPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Initializes a composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
FSTATUS
|
|
Packit |
857059 |
CompPoolInit(
|
|
Packit |
857059 |
IN COMP_POOL* const pCPool,
|
|
Packit |
857059 |
IN const uint32 MinCount,
|
|
Packit |
857059 |
IN const uint32* const ComponentSizes,
|
|
Packit |
857059 |
IN const uint32 NumComponents,
|
|
Packit |
857059 |
IN const uint32 GrowSize,
|
|
Packit |
857059 |
IN CPOOL_CTOR_FUNC pfnConstructor,
|
|
Packit |
857059 |
IN CPOOL_INIT_FUNC pfnInitializer OPTIONAL,
|
|
Packit |
857059 |
IN CPOOL_DTOR_FUNC pfnDestructor OPTIONAL,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Destroys a composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
CompPoolDestroy(
|
|
Packit |
857059 |
IN COMP_POOL* const pCPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Gets an object from a composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline void*
|
|
Packit |
857059 |
CompPoolGet(
|
|
Packit |
857059 |
IN COMP_POOL* const pCPool )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
LIST_ITEM *pListItem;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
ASSERT( pCPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
pListItem = QCompPoolGet( &pCPool->m_QCPool );
|
|
Packit |
857059 |
if( !pListItem )
|
|
Packit |
857059 |
return( NULL );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
return( QListObj( pListItem ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Puts an object back in a composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline void
|
|
Packit |
857059 |
CompPoolPut(
|
|
Packit |
857059 |
IN COMP_POOL* const pCPool,
|
|
Packit |
857059 |
IN void* const pObject )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
LIST_ITEM *pListItem;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
ASSERT( pCPool );
|
|
Packit |
857059 |
ASSERT( pObject );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
pListItem = (LIST_ITEM*)((uchar*)pObject - sizeof(LIST_ITEM));
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* good sanity check */
|
|
Packit |
857059 |
ASSERT( pListItem->pObject == pObject );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
QCompPoolPut( &pCPool->m_QCPool, pListItem );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Grows a composite pool by the specified number of objects.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline FSTATUS
|
|
Packit |
857059 |
CompPoolGrow(
|
|
Packit |
857059 |
IN COMP_POOL* const pCPool,
|
|
Packit |
857059 |
IN uint32 ObjCount )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pCPool );
|
|
Packit |
857059 |
return( QCompPoolGrow( &pCPool->m_QCPool, ObjCount ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Returns the number of objects available in a composite pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline uint32
|
|
Packit |
857059 |
CompPoolCount(
|
|
Packit |
857059 |
IN COMP_POOL* const pCPool )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pCPool );
|
|
Packit |
857059 |
return( QCompPoolCount( &pCPool->m_QCPool ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
****************************************************************************
|
|
Packit |
857059 |
*********** **********
|
|
Packit |
857059 |
*********** DECLARATION OF GROW POOL **********
|
|
Packit |
857059 |
*********** **********
|
|
Packit |
857059 |
****************************************************************************
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Grow pool callback function types.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef void (*GPOOL_CTOR_FUNC)(
|
|
Packit |
857059 |
IN void* const pObject,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef FSTATUS (*GPOOL_INIT_FUNC)(
|
|
Packit |
857059 |
IN void* const pObject,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef void (*GPOOL_DTOR_FUNC)(
|
|
Packit |
857059 |
IN void* const pObject,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Grow pool structure.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef struct _GROW_POOL
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
/* These fields are private and should NOT be directly accessed */
|
|
Packit |
857059 |
QCOMP_POOL m_QCPool;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
GPOOL_CTOR_FUNC m_pfnCtor;
|
|
Packit |
857059 |
GPOOL_INIT_FUNC m_pfnInit;
|
|
Packit |
857059 |
GPOOL_DTOR_FUNC m_pfnDtor;
|
|
Packit |
857059 |
void *m_Context;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
} GROW_POOL;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* Grow pool access methods.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Initializes the state of a grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
GrowPoolInitState(
|
|
Packit |
857059 |
IN GROW_POOL* const pGPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Initialize a grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
FSTATUS
|
|
Packit |
857059 |
GrowPoolInit(
|
|
Packit |
857059 |
IN GROW_POOL* const pGPool,
|
|
Packit |
857059 |
IN const uint32 MinCount,
|
|
Packit |
857059 |
IN uint32 ObjectSize,
|
|
Packit |
857059 |
IN const uint32 GrowSize,
|
|
Packit |
857059 |
IN GPOOL_CTOR_FUNC pfnConstructor OPTIONAL,
|
|
Packit |
857059 |
IN GPOOL_INIT_FUNC pfnInitializer OPTIONAL,
|
|
Packit |
857059 |
IN GPOOL_DTOR_FUNC pnfDestructor OPTIONAL,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Destroy a grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
GrowPoolDestroy(
|
|
Packit |
857059 |
IN GROW_POOL* const pGPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Get an object from a grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline void*
|
|
Packit |
857059 |
GrowPoolGet(
|
|
Packit |
857059 |
IN GROW_POOL* const pGPool )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
LIST_ITEM *pListItem;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
ASSERT( pGPool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
pListItem = QCompPoolGet( &pGPool->m_QCPool );
|
|
Packit |
857059 |
if( !pListItem )
|
|
Packit |
857059 |
return( NULL );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
ASSERT( QListObj( pListItem ) != NULL );
|
|
Packit |
857059 |
return( QListObj( pListItem ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Put an object back in a grow pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline void
|
|
Packit |
857059 |
GrowPoolPut(
|
|
Packit |
857059 |
IN GROW_POOL* const pGPool,
|
|
Packit |
857059 |
void* const pObject )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
LIST_ITEM *pListItem;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
ASSERT( pGPool );
|
|
Packit |
857059 |
ASSERT( pObject );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
pListItem = (LIST_ITEM*)((uchar*)pObject - sizeof(LIST_ITEM));
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* good sanity check */
|
|
Packit |
857059 |
ASSERT( pListItem->pObject == pObject );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
QCompPoolPut( &pGPool->m_QCPool, pListItem );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Grows the resource pool by the specified number of objects.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline FSTATUS
|
|
Packit |
857059 |
GrowPoolGrow(
|
|
Packit |
857059 |
IN GROW_POOL* const pGPool,
|
|
Packit |
857059 |
IN const uint32 ObjCount )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pGPool );
|
|
Packit |
857059 |
return( QCompPoolGrow( &pGPool->m_QCPool, ObjCount ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Returns the number of objects available in the free pool.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
static __inline uint32
|
|
Packit |
857059 |
GrowPoolCount(
|
|
Packit |
857059 |
IN GROW_POOL* const pGPool )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pGPool );
|
|
Packit |
857059 |
return( QCompPoolCount( &pGPool->m_QCPool ) );
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifdef __cplusplus
|
|
Packit |
857059 |
} /* extern "C" */
|
|
Packit |
857059 |
#endif
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#endif /* _IBA_PUBLIC_IGROWPOOL_H_ */
|