fix(globals): keep thread running (#721)
This commit is contained in:
parent
f6c00f113d
commit
d10913743b
@ -3,14 +3,20 @@
|
|||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
|
void menu_settings::destroy()
|
||||||
|
{
|
||||||
|
m_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
void menu_settings::init(const file& save_file)
|
void menu_settings::init(const file& save_file)
|
||||||
{
|
{
|
||||||
|
m_running = true;
|
||||||
m_save_file = std::make_unique<file>(save_file.get_path());
|
m_save_file = std::make_unique<file>(save_file.get_path());
|
||||||
load();
|
load();
|
||||||
|
|
||||||
g_thread_pool->push([this]
|
g_thread_pool->push([this]
|
||||||
{
|
{
|
||||||
while (g_running)
|
while (m_running)
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(100ms);
|
std::this_thread::sleep_for(100ms);
|
||||||
attempt_save();
|
attempt_save();
|
||||||
|
@ -20,6 +20,7 @@ namespace big
|
|||||||
class menu_settings
|
class menu_settings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void destroy();
|
||||||
void init(const file& save_file);
|
void init(const file& save_file);
|
||||||
|
|
||||||
void attempt_save();
|
void attempt_save();
|
||||||
@ -31,6 +32,8 @@ namespace big
|
|||||||
bool write_default_config();
|
bool write_default_config();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_running;
|
||||||
|
|
||||||
std::unique_ptr<file> m_save_file;
|
std::unique_ptr<file> m_save_file;
|
||||||
|
|
||||||
nlohmann::json m_default_options;
|
nlohmann::json m_default_options;
|
||||||
|
@ -133,6 +133,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.";
|
||||||
|
|
||||||
|
// cleans up the thread responsible for saving settings
|
||||||
|
g.destroy();
|
||||||
|
|
||||||
// Make sure that all threads created don't have any blocking loops
|
// Make sure that all threads created don't have any blocking loops
|
||||||
// otherwise make sure that they have stopped executing
|
// otherwise make sure that they have stopped executing
|
||||||
thread_pool_instance->destroy();
|
thread_pool_instance->destroy();
|
||||||
|
Reference in New Issue
Block a user