1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff *
34219820Sjeff */
35219820Sjeff
36219820Sjeff/*
37219820Sjeff * Abstract:
38219820Sjeff *	Declaration of the quick pool.
39219820Sjeff *	The quick pool manages a pool of objects.
40219820Sjeff *	The pool can grow to meet demand, limited only by system memory.
41219820Sjeff */
42219820Sjeff
43219820Sjeff#ifndef _CL_QUICK_POOL_H_
44219820Sjeff#define _CL_QUICK_POOL_H_
45219820Sjeff
46219820Sjeff#include <complib/cl_qcomppool.h>
47219820Sjeff
48219820Sjeff#ifdef __cplusplus
49219820Sjeff#  define BEGIN_C_DECLS extern "C" {
50219820Sjeff#  define END_C_DECLS   }
51219820Sjeff#else				/* !__cplusplus */
52219820Sjeff#  define BEGIN_C_DECLS
53219820Sjeff#  define END_C_DECLS
54219820Sjeff#endif				/* __cplusplus */
55219820Sjeff
56219820SjeffBEGIN_C_DECLS
57219820Sjeff/****h* Component Library/Quick Pool
58219820Sjeff* NAME
59219820Sjeff*	Quick Pool
60219820Sjeff*
61219820Sjeff* DESCRIPTION
62219820Sjeff*	The quick pool provides a self-contained and self-sustaining pool
63219820Sjeff*	of user defined objects.
64219820Sjeff*
65219820Sjeff*	To aid in object oriented design, the quick pool provides the user
66219820Sjeff*	the ability to specify callbacks that are invoked for each object for
67219820Sjeff*	construction, initialization, and destruction. Constructor and destructor
68219820Sjeff*	callback functions may not fail.
69219820Sjeff*
70219820Sjeff*	A quick pool does not return memory to the system as the user returns
71219820Sjeff*	objects to the pool. The only method of returning memory to the system is
72219820Sjeff*	to destroy the pool.
73219820Sjeff*
74219820Sjeff*	The quick pool operates on cl_pool_item_t structures that describe
75219820Sjeff*	objects. This can provides for more efficient memory use and operation.
76219820Sjeff*	If using a cl_pool_item_t is not desired, the Pool provides similar
77219820Sjeff*	functionality but operates on opaque objects.
78219820Sjeff*
79219820Sjeff*	The quick pool functions operates on a cl_qpool_t structure which should
80219820Sjeff*	be treated as opaque and should be manipulated only through the provided
81219820Sjeff*	functions.
82219820Sjeff*
83219820Sjeff* SEE ALSO
84219820Sjeff*	Structures:
85219820Sjeff*		cl_qpool_t, cl_pool_item_t
86219820Sjeff*
87219820Sjeff*	Callbacks:
88219820Sjeff*		cl_pfn_qpool_init_t, cl_pfn_qpool_dtor_t
89219820Sjeff*
90219820Sjeff*	Initialization/Destruction:
91219820Sjeff*		cl_qpool_construct, cl_qpool_init, cl_qpool_destroy
92219820Sjeff*
93219820Sjeff*	Manipulation:
94219820Sjeff*		cl_qpool_get, cl_qpool_put, cl_qpool_put_list, cl_qpool_grow
95219820Sjeff*
96219820Sjeff*	Attributes:
97219820Sjeff*		cl_is_qpool_inited, cl_qpool_count
98219820Sjeff*********/
99219820Sjeff/****d* Component Library: Quick Pool/cl_pfn_qpool_init_t
100219820Sjeff* NAME
101219820Sjeff*	cl_pfn_qpool_init_t
102219820Sjeff*
103219820Sjeff* DESCRIPTION
104219820Sjeff*	The cl_pfn_qpool_init_t function type defines the prototype for
105219820Sjeff*	functions used as constructor for objects being allocated by a
106219820Sjeff*	quick pool.
107219820Sjeff*
108219820Sjeff* SYNOPSIS
109219820Sjeff*/
110219820Sjefftypedef cl_status_t
111219820Sjeff    (*cl_pfn_qpool_init_t) (IN void *const p_object,
112219820Sjeff			    IN void *context,
113219820Sjeff			    OUT cl_pool_item_t ** const pp_pool_item);
114219820Sjeff/*
115219820Sjeff* PARAMETERS
116219820Sjeff*	p_object
117219820Sjeff*		[in] Pointer to an object to initialize.
118219820Sjeff*
119219820Sjeff*	context
120219820Sjeff*		[in] Context provided in a call to cl_qpool_init.
121219820Sjeff*
122219820Sjeff* RETURN VALUES
123219820Sjeff*	Return CL_SUCCESS to indicate that initialization of the object
124219820Sjeff*	was successful and that initialization of further objects may continue.
125219820Sjeff*
126219820Sjeff*	Other cl_status_t values will be returned by cl_qcpool_init
127219820Sjeff*	and cl_qcpool_grow.
128219820Sjeff*
129219820Sjeff* NOTES
130219820Sjeff*	This function type is provided as function prototype reference for
131219820Sjeff*	the function provided by the user as an optional parameter to the
132219820Sjeff*	cl_qpool_init function.
133219820Sjeff*
134219820Sjeff*	The initializer is invoked once per allocated object, allowing the user
135219820Sjeff*	to perform any necessary initialization.  Returning a status other than
136219820Sjeff*	CL_SUCCESS aborts a grow operation, initiated either through cl_qcpool_init
137219820Sjeff*	or cl_qcpool_grow, causing the initiating function to fail.
138219820Sjeff*	Any non-CL_SUCCESS status will be returned by the function that initiated
139219820Sjeff*	the grow operation.
140219820Sjeff*
141219820Sjeff*	All memory for the object is pre-allocated.  Users should include space in
142219820Sjeff*	their objects for the cl_pool_item_t structure that will represent the
143219820Sjeff*	object to avoid having to allocate that structure in the initialization
144219820Sjeff*	callback.
145219820Sjeff*
146219820Sjeff*	When later performing a cl_qcpool_get call, the return value is a pointer
147219820Sjeff*	to the cl_pool_item_t returned by this function in the pp_pool_item
148219820Sjeff*	parameter.  Users must set pp_pool_item to a valid pointer to the
149219820Sjeff*	cl_pool_item_t representing the object if they return CL_SUCCESS.
150219820Sjeff*
151219820Sjeff* SEE ALSO
152219820Sjeff*	Quick Pool, cl_qpool_init
153219820Sjeff*********/
154219820Sjeff
155219820Sjeff/****d* Component Library: Quick Pool/cl_pfn_qpool_dtor_t
156219820Sjeff* NAME
157219820Sjeff*	cl_pfn_qpool_dtor_t
158219820Sjeff*
159219820Sjeff* DESCRIPTION
160219820Sjeff*	The cl_pfn_qpool_dtor_t function type defines the prototype for
161219820Sjeff*	functions used as destructor for objects being deallocated by a
162219820Sjeff*	quick pool.
163219820Sjeff*
164219820Sjeff* SYNOPSIS
165219820Sjeff*/
166219820Sjefftypedef void
167219820Sjeff (*cl_pfn_qpool_dtor_t) (IN const cl_pool_item_t * const p_pool_item,
168219820Sjeff			 IN void *context);
169219820Sjeff/*
170219820Sjeff* PARAMETERS
171219820Sjeff*	p_pool_item
172219820Sjeff*		[in] Pointer to a cl_pool_item_t structure representing an object.
173219820Sjeff*
174219820Sjeff*	context
175219820Sjeff*		[in] Context provided in a call to cl_qpool_init.
176219820Sjeff*
177219820Sjeff* RETURN VALUE
178219820Sjeff*	This function does not return a value.
179219820Sjeff*
180219820Sjeff* NOTES
181219820Sjeff*	This function type is provided as function prototype reference for
182219820Sjeff*	the function provided by the user as an optional parameter to the
183219820Sjeff*	cl_qpool_init function.
184219820Sjeff*
185219820Sjeff*	The destructor is invoked once per allocated object, allowing the user
186219820Sjeff*	to perform any necessary cleanup. Users should not attempt to deallocate
187219820Sjeff*	the memory for the object, as the quick pool manages object
188219820Sjeff*	allocation and deallocation.
189219820Sjeff*
190219820Sjeff* SEE ALSO
191219820Sjeff*	Quick Pool, cl_qpool_init
192219820Sjeff*********/
193219820Sjeff
194219820Sjeff/****s* Component Library: Quick Pool/cl_qpool_t
195219820Sjeff* NAME
196219820Sjeff*	cl_qpool_t
197219820Sjeff*
198219820Sjeff* DESCRIPTION
199219820Sjeff*	Quick pool structure.
200219820Sjeff*
201219820Sjeff*	The cl_qpool_t structure should be treated as opaque and should be
202219820Sjeff*	manipulated only through the provided functions.
203219820Sjeff*
204219820Sjeff* SYNOPSIS
205219820Sjeff*/
206219820Sjefftypedef struct _cl_qpool {
207219820Sjeff	cl_qcpool_t qcpool;
208219820Sjeff	cl_pfn_qpool_init_t pfn_init;
209219820Sjeff	cl_pfn_qpool_dtor_t pfn_dtor;
210219820Sjeff	const void *context;
211219820Sjeff} cl_qpool_t;
212219820Sjeff/*
213219820Sjeff* FIELDS
214219820Sjeff*	qcpool
215219820Sjeff*		Quick composite pool that manages all objects.
216219820Sjeff*
217219820Sjeff*	pfn_init
218219820Sjeff*		Pointer to the user's initializer callback, used by the pool
219219820Sjeff*		to translate the quick composite pool's initializer callback to
220219820Sjeff*		a quick pool initializer callback.
221219820Sjeff*
222219820Sjeff*	pfn_dtor
223219820Sjeff*		Pointer to the user's destructor callback, used by the pool
224219820Sjeff*		to translate the quick composite pool's destructor callback to
225219820Sjeff*		a quick pool destructor callback.
226219820Sjeff*
227219820Sjeff*	context
228219820Sjeff*		User's provided context for callback functions, used by the pool
229219820Sjeff*		to when invoking callbacks.
230219820Sjeff*
231219820Sjeff* SEE ALSO
232219820Sjeff*	Quick Pool
233219820Sjeff*********/
234219820Sjeff
235219820Sjeff/****f* Component Library: Quick Pool/cl_qpool_construct
236219820Sjeff* NAME
237219820Sjeff*	cl_qpool_construct
238219820Sjeff*
239219820Sjeff* DESCRIPTION
240219820Sjeff*	The cl_qpool_construct function constructs a quick pool.
241219820Sjeff*
242219820Sjeff* SYNOPSIS
243219820Sjeff*/
244219820Sjeffvoid cl_qpool_construct(IN cl_qpool_t * const p_pool);
245219820Sjeff/*
246219820Sjeff* PARAMETERS
247219820Sjeff*	p_pool
248219820Sjeff*		[in] Pointer to a cl_qpool_t structure whose state to initialize.
249219820Sjeff*
250219820Sjeff* RETURN VALUE
251219820Sjeff*	This function does not return a value.
252219820Sjeff*
253219820Sjeff* NOTES
254219820Sjeff*	Allows calling cl_qpool_init, cl_qpool_destroy, cl_is_qpool_inited.
255219820Sjeff*
256219820Sjeff*	Calling cl_qpool_construct is a prerequisite to calling any other
257219820Sjeff*	quick pool function except cl_pool_init.
258219820Sjeff*
259219820Sjeff* SEE ALSO
260219820Sjeff*	Quick Pool, cl_qpool_init, cl_qpool_destroy, cl_is_qpool_inited.
261219820Sjeff*********/
262219820Sjeff
263219820Sjeff/****f* Component Library: Quick Pool/cl_is_qpool_inited
264219820Sjeff* NAME
265219820Sjeff*	cl_is_qpool_inited
266219820Sjeff*
267219820Sjeff* DESCRIPTION
268219820Sjeff*	The cl_is_qpool_inited function returns whether a quick pool was
269219820Sjeff*	successfully initialized.
270219820Sjeff*
271219820Sjeff* SYNOPSIS
272219820Sjeff*/
273219820Sjeffstatic inline uint32_t cl_is_qpool_inited(IN const cl_qpool_t * const p_pool)
274219820Sjeff{
275219820Sjeff	/* CL_ASSERT that a non-null pointer is provided. */
276219820Sjeff	CL_ASSERT(p_pool);
277219820Sjeff	return (cl_is_qcpool_inited(&p_pool->qcpool));
278219820Sjeff}
279219820Sjeff
280219820Sjeff/*
281219820Sjeff* PARAMETERS
282219820Sjeff*	p_pool
283219820Sjeff*		[in] Pointer to a cl_qpool_t structure whose initialization state
284219820Sjeff*		to check.
285219820Sjeff*
286219820Sjeff* RETURN VALUES
287219820Sjeff*	TRUE if the quick pool was initialized successfully.
288219820Sjeff*
289219820Sjeff*	FALSE otherwise.
290219820Sjeff*
291219820Sjeff* NOTES
292219820Sjeff*	Allows checking the state of a quick pool to determine if
293219820Sjeff*	invoking member functions is appropriate.
294219820Sjeff*
295219820Sjeff* SEE ALSO
296219820Sjeff*	Quick Pool
297219820Sjeff*********/
298219820Sjeff
299219820Sjeff/****f* Component Library: Quick Pool/cl_qpool_init
300219820Sjeff* NAME
301219820Sjeff*	cl_qpool_init
302219820Sjeff*
303219820Sjeff* DESCRIPTION
304219820Sjeff*	The cl_qpool_init function initializes a quick pool for use.
305219820Sjeff*
306219820Sjeff* SYNOPSIS
307219820Sjeff*/
308219820Sjeffcl_status_t
309219820Sjeffcl_qpool_init(IN cl_qpool_t * const p_pool,
310219820Sjeff	      IN const size_t min_size,
311219820Sjeff	      IN const size_t max_size,
312219820Sjeff	      IN const size_t grow_size,
313219820Sjeff	      IN const size_t object_size,
314219820Sjeff	      IN cl_pfn_qpool_init_t pfn_initializer OPTIONAL,
315219820Sjeff	      IN cl_pfn_qpool_dtor_t pfn_destructor OPTIONAL,
316219820Sjeff	      IN const void *const context);
317219820Sjeff/*
318219820Sjeff* PARAMETERS
319219820Sjeff*	p_pool
320219820Sjeff*		[in] Pointer to a cl_qpool_t structure to initialize.
321219820Sjeff*
322219820Sjeff*	min_size
323219820Sjeff*		[in] Minimum number of objects that the pool should support. All
324219820Sjeff*		necessary allocations to allow storing the minimum number of items
325219820Sjeff*		are performed at initialization time, and all necessary callbacks
326219820Sjeff*		successfully invoked.
327219820Sjeff*
328219820Sjeff*	max_size
329219820Sjeff*		[in] Maximum number of objects to which the pool is allowed to grow.
330219820Sjeff*		A value of zero specifies no maximum.
331219820Sjeff*
332219820Sjeff*	grow_size
333219820Sjeff*		[in] Number of objects to allocate when incrementally growing the pool.
334219820Sjeff*		A value of zero disables automatic growth.
335219820Sjeff*
336219820Sjeff*	object_size
337219820Sjeff*		[in] Size, in bytes, of each object.
338219820Sjeff*
339219820Sjeff*	pfn_initializer
340219820Sjeff*		[in] Initialization callback to invoke for every new object when
341219820Sjeff*		growing the pool. This parameter is optional and may be NULL. If NULL,
342219820Sjeff*		the pool assumes the cl_pool_item_t structure describing objects is
343219820Sjeff*		located at the head of each object. See the cl_pfn_qpool_init_t
344219820Sjeff*		function type declaration for details about the callback function.
345219820Sjeff*
346219820Sjeff*	pfn_destructor
347219820Sjeff*		[in] Destructor callback to invoke for every object before memory for
348219820Sjeff*		that object is freed. This parameter is optional and may be NULL.
349219820Sjeff*		See the cl_pfn_qpool_dtor_t function type declaration for details
350219820Sjeff*		about the callback function.
351219820Sjeff*
352219820Sjeff*	context
353219820Sjeff*		[in] Value to pass to the callback functions to provide context.
354219820Sjeff*
355219820Sjeff* RETURN VALUES
356219820Sjeff*	CL_SUCCESS if the quick pool was initialized successfully.
357219820Sjeff*
358219820Sjeff*	CL_INSUFFICIENT_MEMORY if there was not enough memory to initialize the
359219820Sjeff*	quick pool.
360219820Sjeff*
361219820Sjeff*	CL_INVALID_SETTING if a the maximum size is non-zero and less than the
362219820Sjeff*	minimum size.
363219820Sjeff*
364219820Sjeff*	Other cl_status_t value returned by optional initialization callback function
365219820Sjeff*	specified by the pfn_initializer parameter.
366219820Sjeff*
367219820Sjeff* NOTES
368219820Sjeff*	cl_qpool_init initializes, and if necessary, grows the pool to
369219820Sjeff*	the capacity desired.
370219820Sjeff*
371219820Sjeff* SEE ALSO
372219820Sjeff*	Quick Pool, cl_qpool_construct, cl_qpool_destroy,
373219820Sjeff*	cl_qpool_get, cl_qpool_put, cl_qpool_grow,
374219820Sjeff*	cl_qpool_count, cl_pfn_qpool_init_t, cl_pfn_qpool_init_t,
375219820Sjeff*	cl_pfn_qpool_dtor_t
376219820Sjeff*********/
377219820Sjeff
378219820Sjeff/****f* Component Library: Quick Pool/cl_qpool_destroy
379219820Sjeff* NAME
380219820Sjeff*	cl_qpool_destroy
381219820Sjeff*
382219820Sjeff* DESCRIPTION
383219820Sjeff*	The cl_qpool_destroy function destroys a quick pool.
384219820Sjeff*
385219820Sjeff* SYNOPSIS
386219820Sjeff*/
387219820Sjeffstatic inline void cl_qpool_destroy(IN cl_qpool_t * const p_pool)
388219820Sjeff{
389219820Sjeff	CL_ASSERT(p_pool);
390219820Sjeff	cl_qcpool_destroy(&p_pool->qcpool);
391219820Sjeff}
392219820Sjeff
393219820Sjeff/*
394219820Sjeff* PARAMETERS
395219820Sjeff*	p_pool
396219820Sjeff*		[in] Pointer to a cl_qpool_t structure to destroy.
397219820Sjeff*
398219820Sjeff* RETURN VALUE
399219820Sjeff*	This function does not return a value.
400219820Sjeff*
401219820Sjeff* NOTES
402219820Sjeff*	All memory allocated for objects is freed. The destructor callback,
403219820Sjeff*	if any, will be invoked for every allocated object. Further operations
404219820Sjeff*	on the pool should not be attempted after cl_qpool_destroy
405219820Sjeff*	is invoked.
406219820Sjeff*
407219820Sjeff*	This function should only be called after a call to
408219820Sjeff*	cl_qpool_construct or cl_qpool_init.
409219820Sjeff*
410219820Sjeff*	In a debug build, cl_qpool_destroy asserts that all objects are in
411219820Sjeff*	the pool.
412219820Sjeff*
413219820Sjeff* SEE ALSO
414219820Sjeff*	Quick Pool, cl_qpool_construct, cl_qpool_init
415219820Sjeff*********/
416219820Sjeff
417219820Sjeff/****f* Component Library: Quick Pool/cl_qpool_count
418219820Sjeff* NAME
419219820Sjeff*	cl_qpool_count
420219820Sjeff*
421219820Sjeff* DESCRIPTION
422219820Sjeff*	The cl_qpool_count function returns the number of available objects
423219820Sjeff*	in a quick pool.
424219820Sjeff*
425219820Sjeff* SYNOPSIS
426219820Sjeff*/
427219820Sjeffstatic inline size_t cl_qpool_count(IN cl_qpool_t * const p_pool)
428219820Sjeff{
429219820Sjeff	CL_ASSERT(p_pool);
430219820Sjeff	return (cl_qcpool_count(&p_pool->qcpool));
431219820Sjeff}
432219820Sjeff
433219820Sjeff/*
434219820Sjeff* PARAMETERS
435219820Sjeff*	p_pool
436219820Sjeff*		[in] Pointer to a cl_qpool_t structure for which the number of
437219820Sjeff*		available objects is requested.
438219820Sjeff*
439219820Sjeff* RETURN VALUE
440219820Sjeff*	Returns the number of objects available in the specified quick pool.
441219820Sjeff*
442219820Sjeff* SEE ALSO
443219820Sjeff*	Quick Pool
444219820Sjeff*********/
445219820Sjeff
446219820Sjeff/****f* Component Library: Quick Pool/cl_qpool_get
447219820Sjeff* NAME
448219820Sjeff*	cl_qpool_get
449219820Sjeff*
450219820Sjeff* DESCRIPTION
451219820Sjeff*	The cl_qpool_get function retrieves an object from a
452219820Sjeff*	quick pool.
453219820Sjeff*
454219820Sjeff* SYNOPSIS
455219820Sjeff*/
456219820Sjeffstatic inline cl_pool_item_t *cl_qpool_get(IN cl_qpool_t * const p_pool)
457219820Sjeff{
458219820Sjeff	CL_ASSERT(p_pool);
459219820Sjeff	return (cl_qcpool_get(&p_pool->qcpool));
460219820Sjeff}
461219820Sjeff
462219820Sjeff/*
463219820Sjeff* PARAMETERS
464219820Sjeff*	p_pool
465219820Sjeff*		[in] Pointer to a cl_qpool_t structure from which to retrieve
466219820Sjeff*		an object.
467219820Sjeff*
468219820Sjeff* RETURN VALUES
469219820Sjeff*	Returns a pointer to a cl_pool_item_t for an object.
470219820Sjeff*
471219820Sjeff*	Returns NULL if the pool is empty and can not be grown automatically.
472219820Sjeff*
473219820Sjeff* NOTES
474219820Sjeff*	cl_qpool_get returns the object at the head of the pool. If the pool is
475219820Sjeff*	empty, it is automatically grown to accommodate this request unless the
476219820Sjeff*	grow_size parameter passed to the cl_qpool_init function was zero.
477219820Sjeff*
478219820Sjeff* SEE ALSO
479219820Sjeff*	Quick Pool, cl_qpool_get_tail, cl_qpool_put, cl_qpool_grow, cl_qpool_count
480219820Sjeff*********/
481219820Sjeff
482219820Sjeff/****f* Component Library: Quick Pool/cl_qpool_put
483219820Sjeff* NAME
484219820Sjeff*	cl_qpool_put
485219820Sjeff*
486219820Sjeff* DESCRIPTION
487219820Sjeff*	The cl_qpool_put function returns an object to the head of a quick pool.
488219820Sjeff*
489219820Sjeff* SYNOPSIS
490219820Sjeff*/
491219820Sjeffstatic inline void
492219820Sjeffcl_qpool_put(IN cl_qpool_t * const p_pool,
493219820Sjeff	     IN cl_pool_item_t * const p_pool_item)
494219820Sjeff{
495219820Sjeff	CL_ASSERT(p_pool);
496219820Sjeff	cl_qcpool_put(&p_pool->qcpool, p_pool_item);
497219820Sjeff}
498219820Sjeff
499219820Sjeff/*
500219820Sjeff* PARAMETERS
501219820Sjeff*	p_pool
502219820Sjeff*		[in] Pointer to a cl_qpool_t structure to which to return
503219820Sjeff*		an object.
504219820Sjeff*
505219820Sjeff*	p_pool_item
506219820Sjeff*		[in] Pointer to a cl_pool_item_t structure for the object
507219820Sjeff*		being returned.
508219820Sjeff*
509219820Sjeff* RETURN VALUE
510219820Sjeff*	This function does not return a value.
511219820Sjeff*
512219820Sjeff* NOTES
513219820Sjeff*	cl_qpool_put places the returned object at the head of the pool.
514219820Sjeff*
515219820Sjeff*	The object specified by the p_pool_item parameter must have been
516219820Sjeff*	retrieved from the pool by a previous call to cl_qpool_get.
517219820Sjeff*
518219820Sjeff* SEE ALSO
519219820Sjeff*	Quick Pool, cl_qpool_put_tail, cl_qpool_get
520219820Sjeff*********/
521219820Sjeff
522219820Sjeff/****f* Component Library: Quick Pool/cl_qpool_put_list
523219820Sjeff* NAME
524219820Sjeff*	cl_qpool_put_list
525219820Sjeff*
526219820Sjeff* DESCRIPTION
527219820Sjeff*	The cl_qpool_put_list function returns a list of objects to the head
528219820Sjeff*	of a quick pool.
529219820Sjeff*
530219820Sjeff* SYNOPSIS
531219820Sjeff*/
532219820Sjeffstatic inline void
533219820Sjeffcl_qpool_put_list(IN cl_qpool_t * const p_pool, IN cl_qlist_t * const p_list)
534219820Sjeff{
535219820Sjeff	CL_ASSERT(p_pool);
536219820Sjeff	cl_qcpool_put_list(&p_pool->qcpool, p_list);
537219820Sjeff}
538219820Sjeff
539219820Sjeff/*
540219820Sjeff* PARAMETERS
541219820Sjeff*	p_pool
542219820Sjeff*		[in] Pointer to a cl_qpool_t structure to which to return
543219820Sjeff*		a list of objects.
544219820Sjeff*
545219820Sjeff*	p_list
546219820Sjeff*		[in] Pointer to a cl_qlist_t structure for the list of objects
547219820Sjeff*		being returned.
548219820Sjeff*
549219820Sjeff* RETURN VALUE
550219820Sjeff*	This function does not return a value.
551219820Sjeff*
552219820Sjeff* NOTES
553219820Sjeff*	cl_qpool_put_list places the returned objects at the head of the pool.
554219820Sjeff*
555219820Sjeff*	The objects in the list specified by the p_list parameter must have been
556219820Sjeff*	retrieved from the pool by a previous call to cl_qpool_get.
557219820Sjeff*
558219820Sjeff* SEE ALSO
559219820Sjeff*	Quick Pool, cl_qpool_put, cl_qpool_put_tail, cl_qpool_get
560219820Sjeff*********/
561219820Sjeff
562219820Sjeff/****f* Component Library: Quick Pool/cl_qpool_grow
563219820Sjeff* NAME
564219820Sjeff*	cl_qpool_grow
565219820Sjeff*
566219820Sjeff* DESCRIPTION
567219820Sjeff*	The cl_qpool_grow function grows a quick pool by
568219820Sjeff*	the specified number of objects.
569219820Sjeff*
570219820Sjeff* SYNOPSIS
571219820Sjeff*/
572219820Sjeffstatic inline cl_status_t
573219820Sjeffcl_qpool_grow(IN cl_qpool_t * const p_pool, IN const size_t obj_count)
574219820Sjeff{
575219820Sjeff	CL_ASSERT(p_pool);
576219820Sjeff	return (cl_qcpool_grow(&p_pool->qcpool, obj_count));
577219820Sjeff}
578219820Sjeff
579219820Sjeff/*
580219820Sjeff* PARAMETERS
581219820Sjeff*	p_pool
582219820Sjeff*		[in] Pointer to a cl_qpool_t structure whose capacity to grow.
583219820Sjeff*
584219820Sjeff*	obj_count
585219820Sjeff*		[in] Number of objects by which to grow the pool.
586219820Sjeff*
587219820Sjeff* RETURN VALUES
588219820Sjeff*	CL_SUCCESS if the quick pool grew successfully.
589219820Sjeff*
590219820Sjeff*	CL_INSUFFICIENT_MEMORY if there was not enough memory to grow the
591219820Sjeff*	quick pool.
592219820Sjeff*
593219820Sjeff*	cl_status_t value returned by optional initialization callback function
594219820Sjeff*	specified by the pfn_initializer parameter passed to the
595219820Sjeff*	cl_qpool_init function.
596219820Sjeff*
597219820Sjeff* NOTES
598219820Sjeff*	It is not necessary to call cl_qpool_grow if the pool is
599219820Sjeff*	configured to grow automatically.
600219820Sjeff*
601219820Sjeff* SEE ALSO
602219820Sjeff*	Quick Pool
603219820Sjeff*********/
604219820Sjeff
605219820SjeffEND_C_DECLS
606219820Sjeff#endif				/* _CL_QUICK_POOL_H_ */
607