diff options
-rw-r--r-- | arm_compute/runtime/IPoolManager.h | 7 | ||||
-rw-r--r-- | arm_compute/runtime/PoolManager.h | 5 | ||||
-rw-r--r-- | src/runtime/PoolManager.cpp | 9 |
3 files changed, 17 insertions, 4 deletions
diff --git a/arm_compute/runtime/IPoolManager.h b/arm_compute/runtime/IPoolManager.h index 03cccdd605..4cc3c07b5f 100644 --- a/arm_compute/runtime/IPoolManager.h +++ b/arm_compute/runtime/IPoolManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -53,6 +53,11 @@ public: * @param[in] pool Pool to be managed */ virtual void register_pool(std::unique_ptr<IMemoryPool> pool) = 0; + /** Returns the total number of pools managed by the pool manager + * + * @return Number of managed pools + */ + virtual size_t num_pools() const = 0; }; } // arm_compute #endif /*__ARM_COMPUTE_IPOOLMANAGER_H__ */ diff --git a/arm_compute/runtime/PoolManager.h b/arm_compute/runtime/PoolManager.h index 6549350e8f..509080532a 100644 --- a/arm_compute/runtime/PoolManager.h +++ b/arm_compute/runtime/PoolManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -56,12 +56,13 @@ public: IMemoryPool *lock_pool() override; void unlock_pool(IMemoryPool *pool) override; void register_pool(std::unique_ptr<IMemoryPool> pool) override; + size_t num_pools() const override; private: std::list<std::unique_ptr<IMemoryPool>> _free_pools; /**< List of free pools */ std::list<std::unique_ptr<IMemoryPool>> _occupied_pools; /**< List of occupied pools */ std::unique_ptr<arm_compute::Semaphore> _sem; /**< Semaphore to control the queues */ - arm_compute::Mutex _mtx; /**< Mutex to control access to the queues */ + mutable arm_compute::Mutex _mtx; /**< Mutex to control access to the queues */ }; } // arm_compute #endif /*__ARM_COMPUTE_POOLMANAGER_H__ */ diff --git a/src/runtime/PoolManager.cpp b/src/runtime/PoolManager.cpp index 42cc943e56..293241d6f4 100644 --- a/src/runtime/PoolManager.cpp +++ b/src/runtime/PoolManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -72,3 +72,10 @@ void PoolManager::register_pool(std::unique_ptr<IMemoryPool> pool) // Update semaphore _sem = arm_compute::support::cpp14::make_unique<arm_compute::Semaphore>(_free_pools.size()); } + +size_t PoolManager::num_pools() const +{ + std::lock_guard<arm_compute::Mutex> lock(_mtx); + + return _free_pools.size() + _occupied_pools.size(); +}
\ No newline at end of file |