env: added spdk_mempool_obj_iter
As the name suggests, this function iterates through all elements of the mempool invoking a callback function on each one. It's particularly useful when deinitializing mempool that requires freeing resources tied to each element (e.g. allocated through spdk_mempool_create_ctor). Change-Id: I3da1fee527a36bf99f0b0e2dd3d6f9297422ff25 Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455971 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
819545ae7e
commit
d87493378d
@ -430,6 +430,18 @@ void spdk_mempool_put_bulk(struct spdk_mempool *mp, void **ele_arr, size_t count
|
||||
*/
|
||||
size_t spdk_mempool_count(const struct spdk_mempool *pool);
|
||||
|
||||
/**
|
||||
* Iterate through all elements of the pool and call a function on each one.
|
||||
*
|
||||
* \param mp Memory pool to iterate on.
|
||||
* \param obj_cb Function to call on each element.
|
||||
* \param obj_cb_arg Opaque pointer passed to the callback function.
|
||||
*
|
||||
* \return Number of elements iterated.
|
||||
*/
|
||||
uint32_t spdk_mempool_obj_iter(struct spdk_mempool *mp, spdk_mempool_obj_cb_t obj_cb,
|
||||
void *obj_cb_arg);
|
||||
|
||||
/**
|
||||
* Get the number of dedicated CPU cores utilized by this env abstraction.
|
||||
*
|
||||
|
@ -288,6 +288,14 @@ spdk_mempool_count(const struct spdk_mempool *pool)
|
||||
return rte_mempool_avail_count((struct rte_mempool *)pool);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
spdk_mempool_obj_iter(struct spdk_mempool *mp, spdk_mempool_obj_cb_t obj_cb,
|
||||
void *obj_cb_arg)
|
||||
{
|
||||
return rte_mempool_obj_iter((struct rte_mempool *)mp, (rte_mempool_obj_cb_t *)obj_cb,
|
||||
obj_cb_arg);
|
||||
}
|
||||
|
||||
bool
|
||||
spdk_process_is_primary(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user