diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-10-01 21:03:44 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2024-10-01 21:03:44 +0200 |
commit | b13b5142f1009a71ff06786ac8c8db92891f566a (patch) | |
tree | da6b6ab4b0b47e5ac9b219507c9049c4b59d798b /src/server/worldserver | |
parent | 0d496b14d54d723090ea36760ee0e8d47e53891c (diff) |
Core/Utilities: Extend make_unique_ptr_with_deleter functionality to allow it to create deleters with compile time constant functions (reduces its size to just sizeof(void*))
Diffstat (limited to 'src/server/worldserver')
-rw-r--r-- | src/server/worldserver/Main.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 5f846d79f59..870eb3d5b55 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -153,7 +153,7 @@ int main(int argc, char** argv) GOOGLE_PROTOBUF_VERIFY_VERSION; - auto protobufHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { google::protobuf::ShutdownProtobufLibrary(); }); + auto protobufHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { google::protobuf::ShutdownProtobufLibrary(); }>(&dummy); #ifdef _WIN32 Trinity::Service::Init(serviceLongName, serviceName, serviceDescription, &main, &m_ServiceStatus); @@ -252,7 +252,7 @@ int main(int argc, char** argv) OpenSSLCrypto::threadsSetup(boost::dll::program_location().remove_filename()); - auto opensslHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { OpenSSLCrypto::threadsCleanup(); }); + auto opensslHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { OpenSSLCrypto::threadsCleanup(); }>(&dummy); // Seed the OpenSSL's PRNG here. // That way it won't auto-seed when calling BigNumber::SetRand and slow down the first world login @@ -289,7 +289,7 @@ int main(int argc, char** argv) for (int i = 0; i < numThreads; ++i) threadPool->PostWork([ioContext]() { ioContext->run(); }); - auto ioContextStopHandle = Trinity::make_unique_ptr_with_deleter(ioContext.get(), [](Trinity::Asio::IoContext* ctx) { ctx->stop(); }); + auto ioContextStopHandle = Trinity::make_unique_ptr_with_deleter<&Trinity::Asio::IoContext::stop>(ioContext.get()); // Set process priority according to configuration settings SetProcessPriority("server.worldserver", sConfigMgr->GetIntDefault(CONFIG_PROCESSOR_AFFINITY, 0), sConfigMgr->GetBoolDefault(CONFIG_HIGH_PRIORITY, false)); @@ -298,7 +298,7 @@ int main(int argc, char** argv) if (!StartDB()) return 1; - auto dbHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { StopDB(); }); + auto dbHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { StopDB(); }>(&dummy); if (vm.count("update-databases-only")) return 0; @@ -307,7 +307,7 @@ int main(int argc, char** argv) sRealmList->Initialize(*ioContext, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10)); - auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter(sRealmList, [](RealmList* realmList) { realmList->Close(); }); + auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter<&RealmList::Close>(sRealmList); ///- Get the realm Id from the configuration file uint32 realmId = sConfigMgr->GetIntDefault("RealmID", 0); @@ -349,27 +349,27 @@ int main(int argc, char** argv) metric->Unload(); }); - auto scriptReloadMgrHandle = Trinity::make_unique_ptr_with_deleter(sScriptReloadMgr, [](ScriptReloadMgr* mgr) { mgr->Unload(); }); + auto scriptReloadMgrHandle = Trinity::make_unique_ptr_with_deleter<&ScriptReloadMgr::Unload>(sScriptReloadMgr); sScriptMgr->SetScriptLoader(AddScripts); - auto sScriptMgrHandle = Trinity::make_unique_ptr_with_deleter(sScriptMgr, [](ScriptMgr* mgr) { mgr->Unload(); }); + auto sScriptMgrHandle = Trinity::make_unique_ptr_with_deleter<&ScriptMgr::Unload>(sScriptMgr); // Initialize the World sSecretMgr->Initialize(SECRET_OWNER_WORLDSERVER); if (!sWorld->SetInitialWorldSettings()) return 1; - auto instanceLockMgrHandle = Trinity::make_unique_ptr_with_deleter(&sInstanceLockMgr, [](InstanceLockMgr* mgr) { mgr->Unload(); }); + auto instanceLockMgrHandle = Trinity::make_unique_ptr_with_deleter<&InstanceLockMgr::Unload>(&sInstanceLockMgr); - auto terrainMgrHandle = Trinity::make_unique_ptr_with_deleter(&sTerrainMgr, [](TerrainMgr* mgr) { mgr->UnloadAll(); }); + auto terrainMgrHandle = Trinity::make_unique_ptr_with_deleter<&TerrainMgr::UnloadAll>(&sTerrainMgr); - auto outdoorPvpMgrHandle = Trinity::make_unique_ptr_with_deleter(sOutdoorPvPMgr, [](OutdoorPvPMgr* mgr) { mgr->Die(); }); + auto outdoorPvpMgrHandle = Trinity::make_unique_ptr_with_deleter<&OutdoorPvPMgr::Die>(sOutdoorPvPMgr); // unload all grids (including locked in memory) - auto mapManagementHandle = Trinity::make_unique_ptr_with_deleter(sMapMgr, [](MapManager* mgr) { mgr->UnloadAll(); }); + auto mapManagementHandle = Trinity::make_unique_ptr_with_deleter<&MapManager::UnloadAll>(sMapMgr); // unload battleground templates before different singletons destroyed - auto battlegroundMgrHandle = Trinity::make_unique_ptr_with_deleter(sBattlegroundMgr, [](BattlegroundMgr* mgr) { mgr->DeleteAllBattlegrounds(); }); + auto battlegroundMgrHandle = Trinity::make_unique_ptr_with_deleter<&BattlegroundMgr::DeleteAllBattlegrounds>(sBattlegroundMgr); // Start the Remote Access port (acceptor) if enabled std::unique_ptr<AsyncAcceptor> raAcceptor; |