Add a PreCleanPool() static method to pool item types.
(cherry picked from commit 87142ed840
)
This commit is contained in:
@@ -196,6 +196,7 @@ DEFINE_POOL_METHOD(void)::FreeItem(size_t index)
|
|||||||
DEFINE_POOL_METHOD(void)::CleanPool()
|
DEFINE_POOL_METHOD(void)::CleanPool()
|
||||||
{
|
{
|
||||||
this->cleaning = true;
|
this->cleaning = true;
|
||||||
|
Titem::PreCleanPool();
|
||||||
for (size_t i = 0; i < this->first_unused; i++) {
|
for (size_t i = 0; i < this->first_unused; i++) {
|
||||||
delete this->Get(i); // 'delete NULL;' is very valid
|
delete this->Get(i); // 'delete NULL;' is very valid
|
||||||
}
|
}
|
||||||
|
@@ -286,6 +286,13 @@ struct Pool : PoolBase {
|
|||||||
* @note it's called only when !CleaningPool()
|
* @note it's called only when !CleaningPool()
|
||||||
*/
|
*/
|
||||||
static inline void PostDestructor(size_t index) { }
|
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:
|
private:
|
||||||
|
Reference in New Issue
Block a user