feat(Main): Init and destroy thread pool

This commit is contained in:
Yimura 2021-09-18 22:09:07 +02:00
parent 86c8e94082
commit 3188b044af
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682

View File

@ -7,6 +7,7 @@
#include "pointers.hpp" #include "pointers.hpp"
#include "renderer.hpp" #include "renderer.hpp"
#include "script_mgr.hpp" #include "script_mgr.hpp"
#include "thread_pool.hpp"
BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
{ {
@ -40,6 +41,9 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
g.load(); g.load();
LOG(INFO) << "Settings Loaded."; LOG(INFO) << "Settings Loaded.";
auto thread_pool_instance = std::make_unique<thread_pool>();
LOG(INFO) << "Thread pool initialized.";
g_script_mgr.add_script(std::make_unique<script>(&features::script_func)); g_script_mgr.add_script(std::make_unique<script>(&features::script_func));
g_script_mgr.add_script(std::make_unique<script>(&gui::script_func)); g_script_mgr.add_script(std::make_unique<script>(&gui::script_func));
LOG(INFO) << "Scripts registered."; LOG(INFO) << "Scripts registered.";
@ -54,6 +58,9 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
std::this_thread::sleep_for(500ms); std::this_thread::sleep_for(500ms);
} }
g_thread_pool->destroy();
LOG(INFO) << "Destroyed thread pool.";
g_hooking->disable(); g_hooking->disable();
LOG(INFO) << "Hooking disabled."; LOG(INFO) << "Hooking disabled.";
@ -62,6 +69,9 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
g_script_mgr.remove_all_scripts(); g_script_mgr.remove_all_scripts();
LOG(INFO) << "Scripts unregistered."; LOG(INFO) << "Scripts unregistered.";
thread_pool_instance.reset();
LOG(INFO) << "Thread pool uninitialized.";
hooking_instance.reset(); hooking_instance.reset();
LOG(INFO) << "Hooking uninitialized."; LOG(INFO) << "Hooking uninitialized.";
@ -73,6 +83,8 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
pointers_instance.reset(); pointers_instance.reset();
LOG(INFO) << "Pointers uninitialized."; LOG(INFO) << "Pointers uninitialized.";
vehicle_service_instance.reset();
} }
catch (std::exception const &ex) catch (std::exception const &ex)
{ {