|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
|
|
Packit Service |
54dbc3 |
* Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
|
|
Packit Service |
54dbc3 |
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* This software is available to you under a choice of one of two
|
|
Packit Service |
54dbc3 |
* licenses. You may choose to be licensed under the terms of the GNU
|
|
Packit Service |
54dbc3 |
* General Public License (GPL) Version 2, available from the file
|
|
Packit Service |
54dbc3 |
* COPYING in the main directory of this source tree, or the
|
|
Packit Service |
54dbc3 |
* OpenIB.org BSD license below:
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Redistribution and use in source and binary forms, with or
|
|
Packit Service |
54dbc3 |
* without modification, are permitted provided that the following
|
|
Packit Service |
54dbc3 |
* conditions are met:
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* - Redistributions of source code must retain the above
|
|
Packit Service |
54dbc3 |
* copyright notice, this list of conditions and the following
|
|
Packit Service |
54dbc3 |
* disclaimer.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* - Redistributions in binary form must reproduce the above
|
|
Packit Service |
54dbc3 |
* copyright notice, this list of conditions and the following
|
|
Packit Service |
54dbc3 |
* disclaimer in the documentation and/or other materials
|
|
Packit Service |
54dbc3 |
* provided with the distribution.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
Packit Service |
54dbc3 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
Packit Service |
54dbc3 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
Packit Service |
54dbc3 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
Packit Service |
54dbc3 |
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
Packit Service |
54dbc3 |
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit Service |
54dbc3 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
Packit Service |
54dbc3 |
* SOFTWARE.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* Abstract:
|
|
Packit Service |
54dbc3 |
* Declaration of the quick composite pool. The quick composite pool
|
|
Packit Service |
54dbc3 |
* manages a pool of composite objects. A composite object is an object
|
|
Packit Service |
54dbc3 |
* that is made of multiple sub objects.
|
|
Packit Service |
54dbc3 |
* It can grow to meet demand, limited only by system memory.
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
#ifndef _CL_QUICK_COMPOSITE_POOL_H_
|
|
Packit Service |
54dbc3 |
#define _CL_QUICK_COMPOSITE_POOL_H_
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
#include <complib/cl_types.h>
|
|
Packit Service |
54dbc3 |
#include <complib/cl_qlist.h>
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
#ifdef __cplusplus
|
|
Packit Service |
54dbc3 |
# define BEGIN_C_DECLS extern "C" {
|
|
Packit Service |
54dbc3 |
# define END_C_DECLS }
|
|
Packit Service |
54dbc3 |
#else /* !__cplusplus */
|
|
Packit Service |
54dbc3 |
# define BEGIN_C_DECLS
|
|
Packit Service |
54dbc3 |
# define END_C_DECLS
|
|
Packit Service |
54dbc3 |
#endif /* __cplusplus */
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
BEGIN_C_DECLS
|
|
Packit Service |
54dbc3 |
/****h* Component Library/Quick Composite Pool
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The Quick Composite Pool provides a self-contained and self-sustaining
|
|
Packit Service |
54dbc3 |
* pool of user defined composite objects.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* A composite object is an object that is composed of one or more
|
|
Packit Service |
54dbc3 |
* sub-objects, each of which needs to be treated separately for
|
|
Packit Service |
54dbc3 |
* initialization. Objects can be retrieved from the pool as long as there
|
|
Packit Service |
54dbc3 |
* is memory in the system.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* To aid in object oriented design, the Quick Composite Pool provides users
|
|
Packit Service |
54dbc3 |
* the ability to specify callbacks that are invoked for each object for
|
|
Packit Service |
54dbc3 |
* construction, initialization, and destruction. Constructor and destructor
|
|
Packit Service |
54dbc3 |
* callback functions may not fail.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* A Quick Composite Pool does not return memory to the system as the user
|
|
Packit Service |
54dbc3 |
* returns objects to the pool. The only method of returning memory to the
|
|
Packit Service |
54dbc3 |
* system is to destroy the pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* The Quick Composite Pool operates on cl_pool_item_t structures that
|
|
Packit Service |
54dbc3 |
* describe composite objects. This provides for more efficient memory use.
|
|
Packit Service |
54dbc3 |
* If using a cl_pool_item_t is not desired, the Composite Pool provides
|
|
Packit Service |
54dbc3 |
* similar functionality but operates on opaque objects.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* The Quick Composit Pool functions operate on a cl_qcpool_t structure
|
|
Packit Service |
54dbc3 |
* which should be treated as opaque and should be manipulated only through
|
|
Packit Service |
54dbc3 |
* the provided functions.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Structures:
|
|
Packit Service |
54dbc3 |
* cl_qcpool_t, cl_pool_item_t
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Callbacks:
|
|
Packit Service |
54dbc3 |
* cl_pfn_qcpool_init_t, cl_pfn_qcpool_dtor_t
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Initialization/Destruction:
|
|
Packit Service |
54dbc3 |
* cl_qcpool_construct, cl_qcpool_init, cl_qcpool_destroy
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Manipulation:
|
|
Packit Service |
54dbc3 |
* cl_qcpool_get, cl_qcpool_put, cl_qcpool_put_list, cl_qcpool_grow
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Attributes:
|
|
Packit Service |
54dbc3 |
* cl_is_qcpool_inited, cl_qcpool_count
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
/****s* Component Library: Quick Composite Pool/cl_pool_item_t
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_pool_item_t
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_pool_item_t structure is used by pools to store objects.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
typedef struct _cl_pool_item {
|
|
Packit Service |
54dbc3 |
cl_list_item_t list_item;
|
|
Packit Service |
54dbc3 |
#ifdef _DEBUG_
|
|
Packit Service |
54dbc3 |
/* Pointer to the owner pool used for sanity checks. */
|
|
Packit Service |
54dbc3 |
struct _cl_qcpool *p_pool;
|
|
Packit Service |
54dbc3 |
#endif
|
|
Packit Service |
54dbc3 |
} cl_pool_item_t;
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* FIELDS
|
|
Packit Service |
54dbc3 |
* list_item
|
|
Packit Service |
54dbc3 |
* Used internally by the pool. Users should not use this field.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* Used internally by the pool in debug builds to check for consistency.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* The pool item structure is defined in such a way as to safely allow
|
|
Packit Service |
54dbc3 |
* users to cast from a pool item to a list item for storing items
|
|
Packit Service |
54dbc3 |
* retrieved from a quick pool in a quick list.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_list_item_t
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****i* Component Library: Quick List/cl_pool_obj_t
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_pool_obj_t
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_pool_obj_t structure is used by pools to store objects.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
typedef struct _cl_pool_obj {
|
|
Packit Service |
54dbc3 |
/* The pool item must be the first item to allow casting. */
|
|
Packit Service |
54dbc3 |
cl_pool_item_t pool_item;
|
|
Packit Service |
54dbc3 |
const void *p_object;
|
|
Packit Service |
54dbc3 |
} cl_pool_obj_t;
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* FIELDS
|
|
Packit Service |
54dbc3 |
* pool_item
|
|
Packit Service |
54dbc3 |
* Used internally by the pool. Users should not use this field.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* p_object
|
|
Packit Service |
54dbc3 |
* Pointer to the user's object being stored in the pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* The pool object structure is used by non-quick pools to store object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* cl_pool_item_t
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****d* Component Library: Quick Composite Pool/cl_pfn_qcpool_init_t
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_pfn_qcpool_init_t
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_pfn_qcpool_init_t function type defines the prototype for
|
|
Packit Service |
54dbc3 |
* functions used as initializer for objects being allocated by a
|
|
Packit Service |
54dbc3 |
* quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
typedef cl_status_t
|
|
Packit Service |
54dbc3 |
(*cl_pfn_qcpool_init_t) (IN void **const p_comp_array,
|
|
Packit Service |
54dbc3 |
IN const uint32_t num_components,
|
|
Packit Service |
54dbc3 |
IN void *context,
|
|
Packit Service |
54dbc3 |
OUT cl_pool_item_t ** const pp_pool_item);
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_comp_array
|
|
Packit Service |
54dbc3 |
* [in] Pointer to the first entry in an array of pointers, each of
|
|
Packit Service |
54dbc3 |
* which points to a component that makes up a composite object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* num_components
|
|
Packit Service |
54dbc3 |
* [in] Number of components in the component array.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* context
|
|
Packit Service |
54dbc3 |
* [in] Context provided in a call to cl_qcpool_init.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* pp_pool_item
|
|
Packit Service |
54dbc3 |
* [out] Users should set this pointer to reference the cl_pool_item_t
|
|
Packit Service |
54dbc3 |
* structure that represents the composite object. This pointer must
|
|
Packit Service |
54dbc3 |
* not be NULL if the function returns CL_SUCCESS.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUE
|
|
Packit Service |
54dbc3 |
* Return CL_SUCCESS to indicate that initialization of the object
|
|
Packit Service |
54dbc3 |
* was successful and that initialization of further objects may continue.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Other cl_status_t values will be returned by cl_qcpool_init
|
|
Packit Service |
54dbc3 |
* and cl_qcpool_grow.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* This function type is provided as function prototype reference for
|
|
Packit Service |
54dbc3 |
* the function provided by the user as a parameter to the
|
|
Packit Service |
54dbc3 |
* cl_qcpool_init function.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* The initializer is invoked once per allocated object, allowing the user
|
|
Packit Service |
54dbc3 |
* to chain components to form a composite object and perform any necessary
|
|
Packit Service |
54dbc3 |
* initialization. Returning a status other than CL_SUCCESS aborts a grow
|
|
Packit Service |
54dbc3 |
* operation, initiated either through cl_qcpool_init or cl_qcpool_grow,
|
|
Packit Service |
54dbc3 |
* and causes the initiating function to fail. Any non-CL_SUCCESS status
|
|
Packit Service |
54dbc3 |
* will be returned by the function that initiated the grow operation.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* All memory for the requested number of components is pre-allocated. Users
|
|
Packit Service |
54dbc3 |
* should include space in one of their components for the cl_pool_item_t
|
|
Packit Service |
54dbc3 |
* structure that will represent the composite object to avoid having to
|
|
Packit Service |
54dbc3 |
* allocate that structure in the initialization callback. Alternatively,
|
|
Packit Service |
54dbc3 |
* users may specify an additional component for the cl_pool_item_t structure.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* When later performing a cl_qcpool_get call, the return value is a pointer
|
|
Packit Service |
54dbc3 |
* to the cl_pool_item_t returned by this function in the pp_pool_item
|
|
Packit Service |
54dbc3 |
* parameter. Users must set pp_pool_item to a valid pointer to the
|
|
Packit Service |
54dbc3 |
* cl_pool_item_t representing the object if they return CL_SUCCESS.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_qcpool_init
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****d* Component Library: Quick Composite Pool/cl_pfn_qcpool_dtor_t
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_pfn_qcpool_dtor_t
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_pfn_qcpool_dtor_t function type defines the prototype for
|
|
Packit Service |
54dbc3 |
* functions used as destructor for objects being deallocated by a
|
|
Packit Service |
54dbc3 |
* quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
typedef void
|
|
Packit Service |
54dbc3 |
(*cl_pfn_qcpool_dtor_t) (IN const cl_pool_item_t * const p_pool_item,
|
|
Packit Service |
54dbc3 |
IN void *context);
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool_item
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_pool_item_t structure representing an object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* context
|
|
Packit Service |
54dbc3 |
* [in] Context provided in a call to cl_qcpool_init.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUE
|
|
Packit Service |
54dbc3 |
* This function does not return a value.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* This function type is provided as function prototype reference for
|
|
Packit Service |
54dbc3 |
* the function provided by the user as an optional parameter to the
|
|
Packit Service |
54dbc3 |
* cl_qcpool_init function.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* The destructor is invoked once per allocated object, allowing the user
|
|
Packit Service |
54dbc3 |
* to perform any necessary cleanup. Users should not attempt to deallocate
|
|
Packit Service |
54dbc3 |
* the memory for the composite object, as the quick composite pool manages
|
|
Packit Service |
54dbc3 |
* object allocation and deallocation.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_qcpool_init
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****s* Component Library: Quick Composite Pool/cl_qcpool_t
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_t
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* Quick composite pool structure.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_t structure should be treated as opaque and should be
|
|
Packit Service |
54dbc3 |
* manipulated only through the provided functions.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
typedef struct _cl_qcpool {
|
|
Packit Service |
54dbc3 |
uint32_t num_components;
|
|
Packit Service |
54dbc3 |
size_t *component_sizes;
|
|
Packit Service |
54dbc3 |
void **p_components;
|
|
Packit Service |
54dbc3 |
size_t num_objects;
|
|
Packit Service |
54dbc3 |
size_t max_objects;
|
|
Packit Service |
54dbc3 |
size_t grow_size;
|
|
Packit Service |
54dbc3 |
cl_pfn_qcpool_init_t pfn_init;
|
|
Packit Service |
54dbc3 |
cl_pfn_qcpool_dtor_t pfn_dtor;
|
|
Packit Service |
54dbc3 |
const void *context;
|
|
Packit Service |
54dbc3 |
cl_qlist_t free_list;
|
|
Packit Service |
54dbc3 |
cl_qlist_t alloc_list;
|
|
Packit Service |
54dbc3 |
cl_state_t state;
|
|
Packit Service |
54dbc3 |
} cl_qcpool_t;
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* FIELDS
|
|
Packit Service |
54dbc3 |
* num_components
|
|
Packit Service |
54dbc3 |
* Number of components per object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* component_sizes
|
|
Packit Service |
54dbc3 |
* Array of sizes, one for each component.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* p_components
|
|
Packit Service |
54dbc3 |
* Array of pointers to components, used for the constructor callback.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* num_objects
|
|
Packit Service |
54dbc3 |
* Number of objects managed by the pool
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* max_objects
|
|
Packit Service |
54dbc3 |
* Maximum number of objects allowed to be created in pool
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* grow_size
|
|
Packit Service |
54dbc3 |
* Number of objects to add when automatically growing the pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* pfn_init
|
|
Packit Service |
54dbc3 |
* Pointer to the user's initializer callback to invoke when initializing
|
|
Packit Service |
54dbc3 |
* new objects.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* pfn_dtor
|
|
Packit Service |
54dbc3 |
* Pointer to the user's destructor callback to invoke before deallocating
|
|
Packit Service |
54dbc3 |
* memory allocated for objects.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* context
|
|
Packit Service |
54dbc3 |
* User's provided context for callback functions, used by the pool
|
|
Packit Service |
54dbc3 |
* when invoking callbacks.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* free_list
|
|
Packit Service |
54dbc3 |
* Quick list of objects available.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* alloc_list
|
|
Packit Service |
54dbc3 |
* Quick list used to store information about allocations.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* state
|
|
Packit Service |
54dbc3 |
* State of the pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_qcpool_construct
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_construct
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_construct function constructs a quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
void cl_qcpool_construct(IN cl_qcpool_t * const p_pool);
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure whose state to initialize.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUE
|
|
Packit Service |
54dbc3 |
* This function does not return a value.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* Allows calling cl_qcpool_init, cl_qcpool_destroy, cl_is_qcpool_inited.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Calling cl_qcpool_construct is a prerequisite to calling any other
|
|
Packit Service |
54dbc3 |
* quick composite pool function except cl_qcpool_init.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_qcpool_init, cl_qcpool_destroy,
|
|
Packit Service |
54dbc3 |
* cl_is_qcpool_inited
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_is_qcpool_inited
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_is_qcpool_inited
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_is_qcpool_inited function returns whether a quick composite pool was
|
|
Packit Service |
54dbc3 |
* successfully initialized.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
static inline uint32_t cl_is_qcpool_inited(IN const cl_qcpool_t * const p_pool)
|
|
Packit Service |
54dbc3 |
{
|
|
Packit Service |
54dbc3 |
/* CL_ASSERT that a non-null pointer is provided. */
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool);
|
|
Packit Service |
54dbc3 |
/* CL_ASSERT that the pool is not in some invalid state. */
|
|
Packit Service |
54dbc3 |
CL_ASSERT(cl_is_state_valid(p_pool->state));
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
return (p_pool->state == CL_INITIALIZED);
|
|
Packit Service |
54dbc3 |
}
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure to check.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUES
|
|
Packit Service |
54dbc3 |
* TRUE if the quick composite pool was initialized successfully.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* FALSE otherwise.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* Allows checking the state of a quick composite pool to determine if
|
|
Packit Service |
54dbc3 |
* invoking member functions is appropriate.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_qcpool_init
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_init
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_init function initializes a quick composite pool for use.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
cl_status_t
|
|
Packit Service |
54dbc3 |
cl_qcpool_init(IN cl_qcpool_t * const p_pool,
|
|
Packit Service |
54dbc3 |
IN const size_t min_size,
|
|
Packit Service |
54dbc3 |
IN const size_t max_size,
|
|
Packit Service |
54dbc3 |
IN const size_t grow_size,
|
|
Packit Service |
54dbc3 |
IN const size_t * const component_sizes,
|
|
Packit Service |
54dbc3 |
IN const uint32_t num_components,
|
|
Packit Service |
54dbc3 |
IN cl_pfn_qcpool_init_t pfn_initializer OPTIONAL,
|
|
Packit Service |
54dbc3 |
IN cl_pfn_qcpool_dtor_t pfn_destructor OPTIONAL,
|
|
Packit Service |
54dbc3 |
IN const void *const context);
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure to initialize.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* min_size
|
|
Packit Service |
54dbc3 |
* [in] Minimum number of objects that the pool should support. All
|
|
Packit Service |
54dbc3 |
* necessary allocations to allow storing the minimum number of items
|
|
Packit Service |
54dbc3 |
* are performed at initialization time, and all necessary callbacks
|
|
Packit Service |
54dbc3 |
* successfully invoked.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* max_size
|
|
Packit Service |
54dbc3 |
* [in] Maximum number of objects to which the pool is allowed to grow.
|
|
Packit Service |
54dbc3 |
* A value of zero specifies no maximum.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* grow_size
|
|
Packit Service |
54dbc3 |
* [in] Number of objects to allocate when incrementally growing the pool.
|
|
Packit Service |
54dbc3 |
* A value of zero disables automatic growth.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* component_sizes
|
|
Packit Service |
54dbc3 |
* [in] Pointer to the first entry in an array of sizes describing,
|
|
Packit Service |
54dbc3 |
* in order, the sizes of the components that make up a composite object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* num_components
|
|
Packit Service |
54dbc3 |
* [in] Number of components that make up a composite object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* pfn_initializer
|
|
Packit Service |
54dbc3 |
* [in] Initializer callback to invoke for every new object when growing
|
|
Packit Service |
54dbc3 |
* the pool. This parameter may be NULL only if the objects stored in
|
|
Packit Service |
54dbc3 |
* the quick composite pool consist of only one component. If NULL, the
|
|
Packit Service |
54dbc3 |
* pool assumes the cl_pool_item_t structure describing objects is
|
|
Packit Service |
54dbc3 |
* located at the head of each object. See the cl_pfn_qcpool_init_t
|
|
Packit Service |
54dbc3 |
* function type declaration for details about the callback function.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* pfn_destructor
|
|
Packit Service |
54dbc3 |
* [in] Destructor callback to invoke for every object before memory for
|
|
Packit Service |
54dbc3 |
* that object is freed. This parameter is optional and may be NULL.
|
|
Packit Service |
54dbc3 |
* See the cl_pfn_qcpool_dtor_t function type declaration for details
|
|
Packit Service |
54dbc3 |
* about the callback function.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* context
|
|
Packit Service |
54dbc3 |
* [in] Value to pass to the callback functions to provide context.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUES
|
|
Packit Service |
54dbc3 |
* CL_SUCCESS if the quick composite pool was initialized successfully.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* CL_INSUFFICIENT_MEMORY if there was not enough memory to initialize the
|
|
Packit Service |
54dbc3 |
* quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* CL_INVALID_SETTING if a NULL constructor was provided for composite objects
|
|
Packit Service |
54dbc3 |
* consisting of more than one component. Also returns CL_INVALID_SETTING if
|
|
Packit Service |
54dbc3 |
* the maximum size is non-zero and less than the minimum size.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Other cl_status_t value returned by optional initialization callback function
|
|
Packit Service |
54dbc3 |
* specified by the pfn_initializer parameter.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* If initialization fails, the pool is left in a destroyed state. Callers
|
|
Packit Service |
54dbc3 |
* may still safely call cl_qcpool_destroy.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* cl_qcpool_init initializes, and if necessary, grows the pool to
|
|
Packit Service |
54dbc3 |
* the capacity desired.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_qcpool_construct, cl_qcpool_destroy,
|
|
Packit Service |
54dbc3 |
* cl_qcpool_get, cl_qcpool_put, cl_qcpool_grow,
|
|
Packit Service |
54dbc3 |
* cl_qcpool_count, cl_pfn_qcpool_init_t, cl_pfn_qcpool_dtor_t
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_qcpool_destroy
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_destroy
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_destroy function destroys a quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
void cl_qcpool_destroy(IN cl_qcpool_t * const p_pool);
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure to destroy.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUE
|
|
Packit Service |
54dbc3 |
* This function does not return a value.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* All memory allocated for composite objects is freed. The destructor
|
|
Packit Service |
54dbc3 |
* callback, if any, will be invoked for every allocated object. Further
|
|
Packit Service |
54dbc3 |
* operations on the composite pool should not be attempted after
|
|
Packit Service |
54dbc3 |
* cl_qcpool_destroy is invoked.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* This function should only be called after a call to
|
|
Packit Service |
54dbc3 |
* cl_qcpool_construct or cl_qcpool_init.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* In a debug build, cl_qcpool_destroy asserts that all objects are in
|
|
Packit Service |
54dbc3 |
* the pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_qcpool_construct, cl_qcpool_init
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_qcpool_count
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_count
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_count function returns the number of available objects
|
|
Packit Service |
54dbc3 |
* in a quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
static inline size_t cl_qcpool_count(IN cl_qcpool_t * const p_pool)
|
|
Packit Service |
54dbc3 |
{
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool);
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool->state == CL_INITIALIZED);
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
return (cl_qlist_count(&p_pool->free_list));
|
|
Packit Service |
54dbc3 |
}
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure for which the number of
|
|
Packit Service |
54dbc3 |
* available objects is requested.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUE
|
|
Packit Service |
54dbc3 |
* Returns the number of objects available in the specified
|
|
Packit Service |
54dbc3 |
* quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_qcpool_get
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_get
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_get function retrieves an object from a
|
|
Packit Service |
54dbc3 |
* quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
cl_pool_item_t *cl_qcpool_get(IN cl_qcpool_t * const p_pool);
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure from which to retrieve
|
|
Packit Service |
54dbc3 |
* an object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUES
|
|
Packit Service |
54dbc3 |
* Returns a pointer to a cl_pool_item_t for a composite object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* Returns NULL if the pool is empty and can not be grown automatically.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* cl_qcpool_get returns the object at the head of the pool. If the pool is
|
|
Packit Service |
54dbc3 |
* empty, it is automatically grown to accommodate this request unless the
|
|
Packit Service |
54dbc3 |
* grow_size parameter passed to the cl_qcpool_init function was zero.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_qcpool_get_tail, cl_qcpool_put,
|
|
Packit Service |
54dbc3 |
* cl_qcpool_grow, cl_qcpool_count
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_qcpool_put
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_put
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_put function returns an object to a quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
static inline void
|
|
Packit Service |
54dbc3 |
cl_qcpool_put(IN cl_qcpool_t * const p_pool,
|
|
Packit Service |
54dbc3 |
IN cl_pool_item_t * const p_pool_item)
|
|
Packit Service |
54dbc3 |
{
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool);
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool->state == CL_INITIALIZED);
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool_item);
|
|
Packit Service |
54dbc3 |
/* Make sure items being returned came from the specified pool. */
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool_item->p_pool == p_pool);
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/* return this lil' doggy to the pool */
|
|
Packit Service |
54dbc3 |
cl_qlist_insert_head(&p_pool->free_list, &p_pool_item->list_item);
|
|
Packit Service |
54dbc3 |
}
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure to which to return
|
|
Packit Service |
54dbc3 |
* an object.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* p_pool_item
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_pool_item_t structure for the object
|
|
Packit Service |
54dbc3 |
* being returned.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUE
|
|
Packit Service |
54dbc3 |
* This function does not return a value.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* cl_qcpool_put places the returned object at the head of the pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* The object specified by the p_pool_item parameter must have been
|
|
Packit Service |
54dbc3 |
* retrieved from the pool by a previous call to cl_qcpool_get.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_qcpool_put_tail, cl_qcpool_get
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_qcpool_put_list
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_put_list
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_put_list function returns a list of objects to the head of
|
|
Packit Service |
54dbc3 |
* a quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
static inline void
|
|
Packit Service |
54dbc3 |
cl_qcpool_put_list(IN cl_qcpool_t * const p_pool, IN cl_qlist_t * const p_list)
|
|
Packit Service |
54dbc3 |
{
|
|
Packit Service |
54dbc3 |
#ifdef _DEBUG_
|
|
Packit Service |
54dbc3 |
cl_list_item_t *p_item;
|
|
Packit Service |
54dbc3 |
#endif
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool);
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_pool->state == CL_INITIALIZED);
|
|
Packit Service |
54dbc3 |
CL_ASSERT(p_list);
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
#ifdef _DEBUG_
|
|
Packit Service |
54dbc3 |
/* Check that all items in the list came from this pool. */
|
|
Packit Service |
54dbc3 |
p_item = cl_qlist_head(p_list);
|
|
Packit Service |
54dbc3 |
while (p_item != cl_qlist_end(p_list)) {
|
|
Packit Service |
54dbc3 |
CL_ASSERT(((cl_pool_item_t *) p_item)->p_pool == p_pool);
|
|
Packit Service |
54dbc3 |
p_item = cl_qlist_next(p_item);
|
|
Packit Service |
54dbc3 |
}
|
|
Packit Service |
54dbc3 |
#endif
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
cl_qlist_insert_list_head(&p_pool->free_list, p_list);
|
|
Packit Service |
54dbc3 |
}
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure to which to return
|
|
Packit Service |
54dbc3 |
* a list of objects.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* p_list
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qlist_t structure for the list of objects
|
|
Packit Service |
54dbc3 |
* being returned.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUE
|
|
Packit Service |
54dbc3 |
* This function does not return a value.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* cl_qcpool_put_list places the returned objects at the head of the pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* The objects in the list specified by the p_list parameter must have been
|
|
Packit Service |
54dbc3 |
* retrieved from the pool by a previous call to cl_qcpool_get.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool, cl_qcpool_put, cl_qcpool_put_tail, cl_qcpool_get
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
/****f* Component Library: Quick Composite Pool/cl_qcpool_grow
|
|
Packit Service |
54dbc3 |
* NAME
|
|
Packit Service |
54dbc3 |
* cl_qcpool_grow
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* DESCRIPTION
|
|
Packit Service |
54dbc3 |
* The cl_qcpool_grow function grows a quick composite pool by
|
|
Packit Service |
54dbc3 |
* the specified number of objects.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SYNOPSIS
|
|
Packit Service |
54dbc3 |
*/
|
|
Packit Service |
54dbc3 |
cl_status_t cl_qcpool_grow(IN cl_qcpool_t * const p_pool, IN size_t obj_count);
|
|
Packit Service |
54dbc3 |
/*
|
|
Packit Service |
54dbc3 |
* PARAMETERS
|
|
Packit Service |
54dbc3 |
* p_pool
|
|
Packit Service |
54dbc3 |
* [in] Pointer to a cl_qcpool_t structure whose capacity to grow.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* obj_count
|
|
Packit Service |
54dbc3 |
* [in] Number of objects by which to grow the pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* RETURN VALUES
|
|
Packit Service |
54dbc3 |
* CL_SUCCESS if the quick composite pool grew successfully.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* CL_INSUFFICIENT_MEMORY if there was not enough memory to grow the
|
|
Packit Service |
54dbc3 |
* quick composite pool.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* cl_status_t value returned by optional initialization callback function
|
|
Packit Service |
54dbc3 |
* specified by the pfn_initializer parameter passed to the
|
|
Packit Service |
54dbc3 |
* cl_qcpool_init function.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* NOTES
|
|
Packit Service |
54dbc3 |
* It is not necessary to call cl_qcpool_grow if the pool is
|
|
Packit Service |
54dbc3 |
* configured to grow automatically.
|
|
Packit Service |
54dbc3 |
*
|
|
Packit Service |
54dbc3 |
* SEE ALSO
|
|
Packit Service |
54dbc3 |
* Quick Composite Pool
|
|
Packit Service |
54dbc3 |
*********/
|
|
Packit Service |
54dbc3 |
|
|
Packit Service |
54dbc3 |
END_C_DECLS
|
|
Packit Service |
54dbc3 |
#endif /* _CL_QUICK_COMPOSITE_POOL_H_ */
|