Add a PreCleanPool() static method to pool item types.

(cherry picked from commit 87142ed840)
This commit is contained in:
Jonathan G Rennison
2017-03-04 23:39:27 +00:00
parent a3034891a1
commit 4e9d4dd80a
2 changed files with 8 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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: