fix(globals): keep thread running (#721)

This commit is contained in:
Yimura authored and GitHub committed 2022-12-18 23:22:01 +00:00
1 parent ddddbd4efd
commit 20e53e620f
3 files changed
+13 -1

No files matched your search

+7 -1
View File
@@ -3,14 +3,20 @@
namespace big
{
void menu_settings::destroy()
{
m_running = false;
}
void menu_settings::init(const file& save_file)
{
m_running = true;
m_save_file = std::make_unique<file>(save_file.get_path());
load();
g_thread_pool->push([this]
{
while (g_running)
while (m_running)
{
std::this_thread::sleep_for(100ms);
attempt_save();
+3
View File
@@ -20,6 +20,7 @@ namespace big
class menu_settings
{
public:
void destroy();
void init(const file& save_file);
void attempt_save();
@@ -31,6 +32,8 @@ namespace big
bool write_default_config();
private:
bool m_running;
std::unique_ptr<file> m_save_file;
nlohmann::json m_default_options;
+3
View File
@@ -133,6 +133,9 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
g_script_mgr.remove_all_scripts();
LOG(INFO) << "Scripts unregistered.";
// cleans up the thread responsible for saving settings
g.destroy();
// Make sure that all threads created don't have any blocking loops
// otherwise make sure that they have stopped executing
thread_pool_instance->destroy();