This commit is contained in:
aozhiwei 2023-04-28 19:14:49 +08:00
parent 4564dca5a6
commit 9b9b497ed2
2 changed files with 14 additions and 0 deletions

View File

@ -133,6 +133,9 @@ namespace mt
void MetaMgr::UnInit()
{
for (auto t : meta_tables) {
t->destory_cb();
}
meta_tables.clear();
}

View File

@ -58,6 +58,7 @@ namespace mt
struct MetaTable
{
std::function<void()> destory_cb;
std::function<void()> static_pre_init_cb;
std::function<void()> load_cb;
std::vector<std::function<void()>> init_cbs;
@ -82,6 +83,16 @@ namespace mt
void RegMetaTable(const std::string& dir)
{
std::shared_ptr<mt::MetaTable> p = std::make_shared<mt::MetaTable>();
p->destory_cb =
[] ()
{
for (T* item : T::raw_list) {
delete item;
}
T::raw_list.clear();
T::id_hash.clear();
T::name_hash.clear();
};
p->static_pre_init_cb =
[] ()
{