From 4e9d4dd80adc4cbe9e06016c10535f4f0fea2bc6 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 4 Mar 2017 23:39:27 +0000 Subject: [PATCH] Add a PreCleanPool() static method to pool item types. (cherry picked from commit 87142ed840bb76361bc7a7219d643e49358487dd) --- src/core/pool_func.hpp | 1 + src/core/pool_type.hpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/core/pool_func.hpp b/src/core/pool_func.hpp index 5569addbd7..a5375e13fc 100644 --- a/src/core/pool_func.hpp +++ b/src/core/pool_func.hpp @@ -196,6 +196,7 @@ DEFINE_POOL_METHOD(void)::FreeItem(size_t index) DEFINE_POOL_METHOD(void)::CleanPool() { this->cleaning = true; + Titem::PreCleanPool(); for (size_t i = 0; i < this->first_unused; i++) { delete this->Get(i); // 'delete NULL;' is very valid } diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index 4d20ed1abb..70f6480103 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -286,6 +286,13 @@ struct Pool : PoolBase { * @note it's called only when !CleaningPool() */ static inline void PostDestructor(size_t index) { } + + /** + * Dummy function called before a pool is about to be cleaned. + * If you want to use it, override it in PoolItem's subclass. + * @note it's called only when CleaningPool() + */ + static inline void PreCleanPool() { } }; private: