[{"id":20051,"web_url":"https://patchwork.libcamera.org/comment/20051/","msgid":"<30e49b70-38f5-d9ec-cafd-d22fa7e130df@ideasonboard.com>","date":"2021-10-05T07:03:22","subject":"Re: [libcamera-devel] [PATCH 1/3] ipu3: Remove the usage of\n\tSharedItemPool","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Han-Lin,\n\nThank you for the patch.\n\n\n> From: hanlinchen<hanlinchen@google.com>\n>\n> The SharedItemPool was migrated from Chrome OS to maintain RGBS and AF\n> grids in IPAIPU3Stats. The orginal reason is to reserve the validness\n> unitl the grids are processed in a different thread. However, it leads\n\n\nAh, I think we were not aware of any thread processing in statistics at \nthat point. Yes, maintaining a buffer pool would have made more sense in \nthat case.\n\n> to a subtle bug which recycles the buffer before sending into AIQ\n> libraries. Since the IPU3 IPA (Unlike Chrome OS) process IPAIPU3Stats\n> in a single thread, It would be simpler to maintain the grids as the\n> members of IPAIPU3Stats, and remove the usage of SharedItemPool.\n\n\nAgreed.\n\n>\n> Signed-off-by: Han-Lin Chen<hanlinchen@google.com>\n> ---\n>   stats/ipa_ipu3_stats.cpp   | 145 ++++++-------------------------------\n>   stats/ipa_ipu3_stats.h     |  41 +++++++----\n>   stats/meson.build          |   1 -\n>   stats/shared_item_pool.cpp | 129 ---------------------------------\n>   stats/shared_item_pool.h   | 114 -----------------------------\n>   5 files changed, 47 insertions(+), 383 deletions(-)\n>   delete mode 100644 stats/shared_item_pool.cpp\n>   delete mode 100644 stats/shared_item_pool.h\n>\n> diff --git a/stats/ipa_ipu3_stats.cpp b/stats/ipa_ipu3_stats.cpp\n> index c14bd7e..6697c9b 100644\n> --- a/stats/ipa_ipu3_stats.cpp\n> +++ b/stats/ipa_ipu3_stats.cpp\n> @@ -15,30 +15,22 @@ namespacelibcamera::ipa::ipu3  {\n>   \n>   LOG_DEFINE_CATEGORY(IPAIPU3Stats)\n>   \n> -IPAIPU3Stats::IPAIPU3Stats()\n> -{\n> -\taiqStatsInputParams_ = {};\n> -\n> -\t/* \\todo: Is this fine here or we need separate helper? */\n> -\trgbsGridBuffPool_ =std::make_shared<SharedItemPool<ia_aiq_rgbs_grid>>(\"RgbsGridBuffPool\");\n> -\tafFilterBuffPool_ =std::make_shared<SharedItemPool<ia_aiq_af_grid>>(\"AfFilterBuffPool\");\n> -#define PUBLIC_STATS_POOL_SIZE 9 /* comes from CrOS */\n> -\tint ret = allocateStatBufferPools(PUBLIC_STATS_POOL_SIZE);\n> -\tif (ret < 0)\n> -\t\tLOG(IPAIPU3Stats, Error) << \"Failed to allocate stats grid buffers\";\n> -}\n> -\n> -IPAIPU3Stats::~IPAIPU3Stats()\n> -{\n> -\tfreeStatBufferPools();\n> -\trgbsGridBuffPool_.reset();\n> -\tafFilterBuffPool_.reset();\n> -}\n> -\n>   ia_aiq_statistics_input_params *\n>   IPAIPU3Stats::getInputStatsParams(int  frame,aiq::AiqResults  *results,\n>   \t\t\t\t  const ipu3_uapi_stats_3a *stats)\n>   {\n> +\tIPU3AllStats::ipu3_stats_all_stats  outStats = {};\n> +\tIPU3AllStats::ipu3_stats_get_3a(&outStats, stats);\n> +\n> +\trgbsGrid_.blocks_ptr = rgbsGridBlock_;\n> +\n> +\tafGrid_.filter_response_1 = filterResponse1_;\n> +\tafGrid_.filter_response_2 = filterResponse2_;\n> +\n> +\tIPU3AllStats::intel_skycam_statistics_convert(\n> +\t\t\toutStats.ia_css_4a_statistics, &rgbsGrid_, &afGrid_);\n> +\n> +\taiqStatsInputParams_ = {};\n>   \taiqStatsInputParams_.frame_id = frame;\n>   \taiqStatsInputParams_.frame_ae_parameters = results->ae();\n>   \taiqStatsInputParams_.frame_af_parameters = results->af();\n> @@ -47,117 +39,24 @@IPAIPU3Stats::getInputStatsParams(int  frame,aiq::AiqResults  *results,\n>   \taiqStatsInputParams_.frame_sa_parameters = results->sa();\n>   \taiqStatsInputParams_.camera_orientation = ia_aiq_camera_orientation_unknown;\n>   \n> -\tIPU3AllStats::ipu3_stats_all_stats  outStats;\n> -\tmemset(&outStats, 0, sizeof(IPU3AllStats::ipu3_stats_all_stats));\n> -\tIPU3AllStats::ipu3_stats_get_3a(&outStats, stats);\n> -\n> -\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\n> -\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\n> -\tint ret = afFilterBuffPool_->acquireItem(afGrid);\n> -\tret |= rgbsGridBuffPool_->acquireItem(rgbsGrid);\n> -\tif (ret != 0 || afGrid.get() == nullptr || rgbsGrid.get() == nullptr) {\n> -\t\tLOG(IPAIPU3Stats, Error) << \"Failed to acquire 3A buffers from pools\";\n> -\t\treturn nullptr;\n> -\t}\n> -\n> -\tIPU3AllStats::intel_skycam_statistics_convert(outStats.ia_css_4a_statistics,\n> -\t\t\t\t\t\t      rgbsGrid.get(), afGrid.get());\n> -\n> -\tconst ia_aiq_rgbs_grid *rgbsGridPtr = rgbsGrid.get();\n> -\tconst ia_aiq_af_grid *afGridPtr = afGrid.get();\n> -\n> +\trgbsGridPtr_ = &rgbsGrid_;\n>   \taiqStatsInputParams_.num_rgbs_grids = 1;\n> -\taiqStatsInputParams_.rgbs_grids = &rgbsGridPtr;\n> +\taiqStatsInputParams_.rgbs_grids = &rgbsGridPtr_;\n> +\n> +\tafGridPtr_ = &afGrid_;\n>   \taiqStatsInputParams_.num_af_grids = 1;\n> -\taiqStatsInputParams_.af_grids = &afGridPtr;\n> +\taiqStatsInputParams_.af_grids = &afGridPtr_;\n>   \n>   \taiqStatsInputParams_.hdr_rgbs_grid = nullptr;\n>   \taiqStatsInputParams_.depth_grids = nullptr;\n>   \n> -\treturn &aiqStatsInputParams_;\n> -}\n> +\taiqStatsInputParams_.num_external_histograms = 0;\n> +\taiqStatsInputParams_.external_histograms = nullptr;\n\n\nWe were not setting this earlier, so +1 on adding them\n\n>   \n> -intIPAIPU3Stats::allocateStatBufferPools(int  numBufs)\n> -{\n> -\tint ret = afFilterBuffPool_->init(numBufs);\n> -\tret |= rgbsGridBuffPool_->init(numBufs);\n> -\tif (ret != 0) {\n> -\t\tLOG(IPAIPU3Stats, Error) << \"Failed to initialize 3A statistics pools\";\n> -\t\tfreeStatBufferPools();\n> -\t\treturn -ENOMEM;\n> -\t}\n> -#define IPU3_MAX_STATISTICS_WIDTH 80\n> -#define IPU3_MAX_STATISTICS_HEIGHT 60\n> -\tint maxGridSize = IPU3_MAX_STATISTICS_WIDTH * IPU3_MAX_STATISTICS_HEIGHT;\n> -\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\n> -\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\n> -\n> -\tfor (int allocated = 0; allocated < numBufs; allocated++) {\n> -\t\tret = afFilterBuffPool_->acquireItem(afGrid);\n> -\t\tret |= rgbsGridBuffPool_->acquireItem(rgbsGrid);\n> -\n> -\t\tif (ret != 0 || afGrid.get() == nullptr ||\n> -\t\t    rgbsGrid.get() == nullptr) {\n> -\t\t\tLOG(IPAIPU3Stats, Error) << \"Failed to acquire memory from pools\";\n> -\t\t\tfreeStatBufferPools();\n> -\t\t\treturn -ENOMEM;\n> -\t\t}\n> -\n> -\t\trgbsGrid->blocks_ptr = new rgbs_grid_block[maxGridSize];\n> -\t\trgbsGrid->grid_height = 0;\n> -\t\trgbsGrid->grid_width = 0;\n> -\n> -\t\tafGrid->filter_response_1 = new int[maxGridSize];\n> -\t\tafGrid->filter_response_2 = new int[maxGridSize];\n> -\t\tafGrid->block_height = 0;\n> -\t\tafGrid->block_width = 0;\n> -\t\tafGrid->grid_height = 0;\n> -\t\tafGrid->grid_width = 0;\n> -\t}\n> -\n> -\treturn 0;\n> -}\n> +\t/* \\todo: Fill the face state after the integration of face detection. */\n> +\taiqStatsInputParams_.faces = nullptr;\n\n\nthis too, I like to see more and more fields being set,\n\n>   \n> -voidIPAIPU3Stats::freeStatBufferPools()\n> -{\n> -\tif (!afFilterBuffPool_->isFull() || !rgbsGridBuffPool_->isFull()) {\n> -\t\t/* We will leak if we errored out in allocateStatBufferPools*/\n> -\t\tif (!afFilterBuffPool_->isFull())\n> -\t\t\tLOG(IPAIPU3Stats, Warning) << \"AfFilterBuffPool is leaking\";\n> -\t\tif (!rgbsGridBuffPool_->isFull())\n> -\t\t\tLOG(IPAIPU3Stats, Warning) << \"RgbsGridBuffPool is leaking\";\n> -\t}\n> -\n> -\tint ret;\n> -\tsize_t availableItems = afFilterBuffPool_->availableItems();\n> -\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\n> -\tfor (size_t i = 0; i < availableItems; i++) {\n> -\t\tret = afFilterBuffPool_->acquireItem(afGrid);\n> -\t\tif (ret == 0 && afGrid.get() != nullptr) {\n> -\t\t\tdelete[] afGrid->filter_response_1;\n> -\t\t\tafGrid->filter_response_1 = nullptr;\n> -\t\t\tdelete[] afGrid->filter_response_2;\n> -\t\t\tafGrid->filter_response_2 = nullptr;\n> -\t\t} else {\n> -\t\t\tLOG(IPAIPU3Stats, Warning)\n> -\t\t\t\t<< \"Could not acquire AF filter response \"\n> -\t\t\t\t<< i << \"for deletion - leak?\";\n> -\t\t}\n> -\t}\n> -\n> -\tavailableItems = rgbsGridBuffPool_->availableItems();\n> -\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\n> -\tfor (size_t i = 0; i < availableItems; i++) {\n> -\t\tret = rgbsGridBuffPool_->acquireItem(rgbsGrid);\n> -\t\tif (ret == 0 && rgbsGrid.get() != nullptr) {\n> -\t\t\tdelete[] rgbsGrid->blocks_ptr;\n> -\t\t\trgbsGrid->blocks_ptr = nullptr;\n> -\t\t} else {\n> -\t\t\tLOG(IPAIPU3Stats, Warning)\n> -\t\t\t\t<< \"Could not acquire RGBS grid \" << i\n> -\t\t\t\t<< \"for deletion - leak?\";\n> -\t\t}\n> -\t}\n> +\treturn &aiqStatsInputParams_;\n>   }\n>   \n>   } /* namespacelibcamera::ipa::ipu3  */\n> diff --git a/stats/ipa_ipu3_stats.h b/stats/ipa_ipu3_stats.h\n> index 4320024..5f59558 100644\n> --- a/stats/ipa_ipu3_stats.h\n> +++ b/stats/ipa_ipu3_stats.h\n> @@ -5,38 +5,47 @@\n>    * IPAIPU3Stats.cpp: Generate statistics in IA AIQ consumable format.\n>    */\n>   \n> -#include \"aiq/aiq_results.h\"\n> -\n>   #ifndef IPA_IPU3_STATS_H\n>   #define IPA_IPU3_STATS_H\n>   \n> -#include <ia_imaging/ia_aiq_types.h>\n>   #include <linux/intel-ipu3.h>\n> -\n> -#include \"shared_item_pool.h\"\n> +#include \"aiq/aiq_results.h\"\n>   \n>   namespacelibcamera::ipa::ipu3  {\n>   \n> +constexpr uint32_t IPU3MaxStatisticsWidth = 80;\n> +constexpr uint32_t IPU3MaxStatisticsHeight = 60;\n> +constexpr uint32_t IPU3MaxStatisticsGridSize =\n> +\tIPU3MaxStatisticsWidth * IPU3MaxStatisticsHeight;\n> +\n\n\nAre these max width/height same as ia_aiq_init() call when initializing \nthe library? I think so, probably it makes sense to centralize them \nsomewhere.\n\nThe patch makes sense to me so,\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\nThank you for your work Han-Lin.\n\n>   struct AiqResults;\n>   \n>   class IPAIPU3Stats\n>   {\n>   public:\n> -\tIPAIPU3Stats();\n> -\t~IPAIPU3Stats();\n> +\tIPAIPU3Stats() = default;\n> +\t~IPAIPU3Stats() = default;\n>   \n> -\tia_aiq_statistics_input_params *\n> -\tgetInputStatsParams(int frame,\n> -\t\t\taiq::AiqResults  *results,\n> -\t\t\t    const ipu3_uapi_stats_3a *stats);\n> +\tia_aiq_statistics_input_params* getInputStatsParams(\n> +\t\t\tint frame,\n> +\t\t\taiq::AiqResults  *results,\n> +\t\t\tconst ipu3_uapi_stats_3a *stats);\n>   \n>   private:\n> -\tvoid freeStatBufferPools();\n> -\tint allocateStatBufferPools(int numBufs);\n> +\tia_aiq_statistics_input_params aiqStatsInputParams_ = {};\n> +\n> +\t/*!< ia_aiq_statistics_input_params pointer contents */\n> +\tconst ia_aiq_rgbs_grid* rgbsGridPtr_ = nullptr;\n> +\tconst ia_aiq_af_grid* afGridPtr_ = nullptr;\n> +\tia_aiq_rgbs_grid rgbsGrid_ = {};\n> +\tia_aiq_af_grid afGrid_ = {};\n> +\n> +\t/*!< ia_aiq_rgbs_grid pointer contents */\n> +\trgbs_grid_block rgbsGridBlock_[IPU3MaxStatisticsGridSize] = {};\n>   \n> -\tia_aiq_statistics_input_params aiqStatsInputParams_;\n> -\tstd::shared_ptr<SharedItemPool<ia_aiq_af_grid>> afFilterBuffPool_;\n> -\tstd::shared_ptr<SharedItemPool<ia_aiq_rgbs_grid>> rgbsGridBuffPool_;\n> +\t/*!< ia_aiq_af_grid pointer contents */\n> +\tint filterResponse1_[IPU3MaxStatisticsGridSize] = {};\n> +\tint filterResponse2_[IPU3MaxStatisticsGridSize] = {};\n>   };\n>   \n>   } /* namespacelibcamera::ipa::ipu3  */\n> diff --git a/stats/meson.build b/stats/meson.build\n> index 74ce657..e28a6b9 100644\n> --- a/stats/meson.build\n> +++ b/stats/meson.build\n> @@ -3,6 +3,5 @@\n>   ipu3_ipa_files += files([\n>       'ipa_ipu3_stats.cpp',\n>       'ipu3_all_stats.cpp',\n> -    'shared_item_pool.cpp',\n>   ])\n>   \n> diff --git a/stats/shared_item_pool.cpp b/stats/shared_item_pool.cpp\n> deleted file mode 100644\n> index 326a400..0000000\n> --- a/stats/shared_item_pool.cpp\n> +++ /dev/null\n> @@ -1,129 +0,0 @@\n> -/* SPDX-License-Identifier: Apache-2.0 */\n> -/*\n> - * Copyright (C) 2014-2018 Intel Corporation\n> - *\n> - * This implementation is highly derived from ChromeOS:\n> - *   platform2/camera/hal/intel/ipu3/common/SharedItemPool.cpp\n> - */\n> -\n> -#include <ia_imaging/ia_aiq_types.h>\n> -\n> -#include <libcamera/base/log.h>\n> -\n> -#include \"shared_item_pool.h\"\n> -\n> -namespace libcamera {\n> -\n> -LOG_DEFINE_CATEGORY(SharedItemPool)\n> -\n> -template<class ItemType>\n> -SharedItemPool<ItemType>::SharedItemPool(const char *name)\n> -\t: allocated_(nullptr), capacity_(0), deleter_(this), poolName_(name),\n> -\t  resetter_(nullptr)\n> -{\n> -}\n> -\n> -template<class ItemType>\n> -SharedItemPool<ItemType>::~SharedItemPool()\n> -{\n> -\tdeInit();\n> -}\n> -\n> -template<class ItemType>\n> -int SharedItemPool<ItemType>::init(int32_t capacity, void (*resetter)(ItemType *))\n> -{\n> -\tif (capacity_ != 0) {\n> -\t\tLOG(SharedItemPool, Error) << \"Pool initialized already\";\n> -\t\treturn -ENOSYS;\n> -\t}\n> -\tstd::lock_guard<std::mutex>  l(mutex_);\n> -\tresetter_ = resetter;\n> -\tcapacity_ = capacity;\n> -\tavailable_.reserve(capacity);\n> -\tallocated_ = new ItemType[capacity];\n> -\n> -\tfor (int32_t i = 0; i < capacity; i++)\n> -\t\tavailable_.push_back(&allocated_[i]);\n> -\n> -\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_ << \"init with \" << capacity << \" items\";\n> -\n> -\treturn 0;\n> -}\n> -\n> -template<class ItemType>\n> -bool SharedItemPool<ItemType>::isFull()\n> -{\n> -\tstd::lock_guard<std::mutex>  l(mutex_);\n> -\tbool ret = (available_.size() == capacity_);\n> -\treturn ret;\n> -}\n> -\n> -template<class ItemType>\n> -int SharedItemPool<ItemType>::deInit()\n> -{\n> -\tstd::lock_guard<std::mutex>  l(mutex_);\n> -\tif (capacity_ == 0) {\n> -\t\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\n> -\t\t\t\t\t   << \" isn't initialized or already de-initialized\";\n> -\t\treturn 0;\n> -\t}\n> -\tif (available_.size() != capacity_) {\n> -\t\tLOG(SharedItemPool, Error) << \"Not all items are returned \"\n> -\t\t\t\t\t   << \"when destroying pool \" << poolName_\n> -\t\t\t\t\t   << \"(\" << available_.size() << \"/\" << capacity_ << \")\";\n> -\t}\n> -\n> -\tdelete[] allocated_;\n> -\tallocated_ = nullptr;\n> -\tavailable_.clear();\n> -\tcapacity_ = 0;\n> -\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\n> -\t\t\t\t   << \" deinit done\";\n> -\n> -\treturn 0;\n> -}\n> -\n> -template<class ItemType>\n> -int SharedItemPool<ItemType>::acquireItem(std::shared_ptr<ItemType> &item)\n> -{\n> -\titem.reset();\n> -\tstd::lock_guard<std::mutex>  l(mutex_);\n> -\tif (available_.empty()) {\n> -\t\tLOG(SharedItemPool, Error) << \"Shared pool \" << poolName_\n> -\t\t\t\t\t   << \"is empty\";\n> -\t\treturn -ENOSYS;\n> -\t}\n> -\n> -\tstd::shared_ptr<ItemType> sh(available_[0], deleter_);\n> -\tavailable_.erase(available_.begin());\n> -\titem = sh;\n> -\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\n> -\t\t\t\t   << \"acquire items \" << sh.get();\n> -\treturn 0;\n> -}\n> -\n> -template<class ItemType>\n> -size_t SharedItemPool<ItemType>::availableItems()\n> -{\n> -\tstd::lock_guard<std::mutex>  l(mutex_);\n> -\tsize_t ret = available_.size();\n> -\treturn ret;\n> -}\n> -\n> -template<class ItemType>\n> -int SharedItemPool<ItemType>::_releaseItem(ItemType *item)\n> -{\n> -\tstd::lock_guard<std::mutex>  l(mutex_);\n> -\tif (resetter_)\n> -\t\tresetter_(item);\n> -\n> -\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\n> -\t\t\t\t   << \"returning item \" << item;\n> -\n> -\tavailable_.push_back(item);\n> -\treturn 0;\n> -}\n> -\n> -template class SharedItemPool<ia_aiq_rgbs_grid>;\n> -template class SharedItemPool<ia_aiq_af_grid>;\n> -} /* namespace libcamera */\n> diff --git a/stats/shared_item_pool.h b/stats/shared_item_pool.h\n> deleted file mode 100644\n> index 89dc9b3..0000000\n> --- a/stats/shared_item_pool.h\n> +++ /dev/null\n> @@ -1,114 +0,0 @@\n> -/* SPDX-License-Identifier: Apache-2.0 */\n> -/*\n> - * Copyright (C) 2014-2018 Intel Corporation\n> - *\n> - * This implementation is highly derived from ChromeOS:\n> - *   platform2/camera/hal/intel/ipu3/common/SharedItemPool.h\n> - */\n> -\n> -#ifndef SHARED_ITEM_POOL_H\n> -#define SHARED_ITEM_POOL_H\n> -\n> -#include <memory>\n> -#include <mutex>\n> -#include <pthread.h>\n> -#include <vector>\n> -\n> -/**\n> - * \\class SharedItemPool\n> - *\n> - * Pool of ref counted items. This class creates a pool of items and manages\n> - * the acquisition of them. When all references to this item have disappeared\n> - * The item is returned to the pool.\n> - *\n> - * This class is thread safe, i.e. it can be called from  multiple threads.\n> - * When the element is recycled to the pool it can be reset via a client\n> - * provided method.\n> - *\n> - */\n> -\n> -namespace libcamera {\n> -\n> -template<class ItemType>\n> -class SharedItemPool\n> -{\n> -public:\n> -\tSharedItemPool(const char *name = \"Unnamed\");\n> -\t~SharedItemPool();\n> -\n> -\t/**\n> -\t * Initializes the capacity of the pool. It allocates the objects.\n> -\t * optionally it will take function to reset the item before recycling\n> -\t * it to the pool.\n> -\t * This method is thread safe.\n> -\t *\n> -\t * \\param capacity[IN]: Number of items the pool will hold\n> -\t * \\param resetter[IN]: Function to reset the item before recycling to the\n> -\t *                      pool.\n> -\t * \\return -ENOSYS if trying to initialize twice\n> -\t * \\return 0 If everything went ok.\n> -\t */\n> -\tint init(int32_t capacity, void (*resetter)(ItemType *) = nullptr);\n> -\n> -\tbool isFull();\n> -\n> -\t/**\n> -\t * Free the resources of the pool\n> -\t *\n> -\t * \\return 0 on success\n> -\t */\n> -\tint deInit();\n> -\n> -\t/**\n> -\t * Acquire an item from the pool.\n> -\t * This method is thread safe. Access to the internal acquire/release\n> -\t * methods are protected.\n> -\t * BUT the thread-safety for the utilization of the item after it has been\n> -\t * acquired is the user's responsibility.\n> -\t * Be careful not to provide the same item to multiple threads that write\n> -\t * into it.\n> -\t *\n> -\t * \\param item[OUT] shared pointer to an item.\n> -\t * \\return 0 on success\n> -\t */\n> -\tint acquireItem(std::shared_ptr<ItemType> &item);\n> -\n> -\t/**\n> -\t * Returns the number of currently available items\n> -\t * It there would be issues acquiring the lock the method returns 0\n> -\t * available items.\n> -\t *\n> -\t * \\return item count\n> -\t */\n> -\tsize_t availableItems();\n> -\n> -private:\n> -\tint _releaseItem(ItemType *item);\n> -\n> -\tclass ItemDeleter\n> -\t{\n> -\tpublic:\n> -\t\tItemDeleter(SharedItemPool *pool)\n> -\t\t\t: mPool(pool) {}\n> -\t\tvoid operator()(ItemType *item) const\n> -\t\t{\n> -\t\t\tmPool->_releaseItem(item);\n> -\t\t}\n> -\n> -\tprivate:\n> -\t\tSharedItemPool *mPool;\n> -\t};\n> -\n> -\tstd::vector<ItemType *> available_; /* SharedItemPool doesn't have ownership */\n> -\tItemType *allocated_;\n> -\tsize_t capacity_;\n> -\tItemDeleter deleter_;\n> -\tstd::mutex  mutex_; /* protects available_, allocated_, capacity_ */\n> -\tconst char *poolName_;\n> -\tvoid (*resetter_)(ItemType *);\n> -};\n> -\n> -} /* namespace libcamera */\n> -\n> -#endif /* SHARED_ITEM_POOL_H */\n> -\n> -- 2.33.0.800.g4c38ced690-goog","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6E9D7C3243\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Oct 2021 07:03:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C91A4691B6;\n\tTue,  5 Oct 2021 09:03:29 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 28BA7684C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Oct 2021 09:03:28 +0200 (CEST)","from [192.168.1.106] (unknown [103.238.109.2])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BEA9B25B;\n\tTue,  5 Oct 2021 09:03:26 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"m3ANCKNU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1633417407;\n\tbh=l0V/gzi73lN5bMqKSyPgBmRXpLNkJZRAz/3oaUOwEEg=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=m3ANCKNUumqQGeBfQUcHzFLHwdh4dKOMpgjPTwnM3IpFOD823QON7wxY8Y/Px3bpH\n\tDEZXMXtFH51uyU4mZbZKlVup7oNWPQBR2mq1hizTnZb70OQfs6qj3lpIY3UDRAGlbQ\n\tZdW1l+otKgFtMntApJ/WhqAoEKTDyhRosQ5j9t50=","To":"Han-Lin Chen <hanlinchen@google.com>, libcamera-devel@lists.libcamera.org","References":"<20211004094823.260789-1-hanlinchen@google.com>\n\t<mailman.444.1633340913.837.libcamera-devel@lists.libcamera.org>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<30e49b70-38f5-d9ec-cafd-d22fa7e130df@ideasonboard.com>","Date":"Tue, 5 Oct 2021 12:33:22 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<mailman.444.1633340913.837.libcamera-devel@lists.libcamera.org>","Content-Type":"multipart/alternative;\n\tboundary=\"------------17AC1396EC230DD76A78DD5E\"","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH 1/3] ipu3: Remove the usage of\n\tSharedItemPool","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]