}
void PoolBase::destroy(void *obj)
+{
+ if(_destroy(obj))
+ throw invalid_argument("PoolBase::destroy");
+}
+
+
+int PoolBase::_destroy(void *obj)
{
unsigned block_index = 0;
unsigned object_index = BLOCK_SIZE;
}
if(object_index>=BLOCK_SIZE)
- throw invalid_argument("PoolBase::destroy");
+ {
+ for(PoolBase *p: derived_pools)
+ {
+ int result = p->_destroy(obj);
+ if(result!=1)
+ return result;
+ }
+ return 1;
+ }
FlagType *flags = reinterpret_cast<FlagType *>(blocks[block_index]+BLOCK_SIZE*object_size);
FlagType bit = 1<<(object_index%FLAG_BITS);
if(!(flags[object_index/FLAG_BITS]&bit))
- throw invalid_argument("PoolBase::destroy");
+ return 2;
deleter(obj);
flags[object_index/FLAG_BITS] &= ~bit;
--object_count;
free_list[object_count] = block_index*BLOCK_SIZE+object_index;
+
+ return 0;
}
} // namespace Msp::Game
public:
std::uint32_t get_capacity() const { return capacity; }
void destroy(void *);
+
+private:
+ int _destroy(void *);
};
++flags;
}
}
+
+ for(PoolBase *p: derived_pools)
+ p->iterate_objects(func);
}