1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-07-03 02:18:43 +00:00

Minor fixes to config handler

Added Enable and Disable functions
the thread running bool is now properly set to false upon disabling conifg
Enable now returns early if the timer was already created
CheckForFileChanges is called once when initializing
This commit is contained in:
cathery 2020-03-02 18:23:41 +03:00
parent 6898d056d4
commit 42f14cd74c
2 changed files with 20 additions and 2 deletions

View File

@ -181,6 +181,7 @@ namespace syscon::config
void ConfigChangedCheckThreadFunc(void *arg)
{
WriteToLog("Starting config check thread!");
do {
if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, 0)))
{
@ -239,6 +240,7 @@ namespace syscon::config
else
WriteToLog("Failed to read from dualshock 4 config!");
}
bool CheckForFileChanges()
{
static u64 globalConfigLastModified;
@ -305,15 +307,28 @@ namespace syscon::config
Result Initialize()
{
config::LoadAllConfigs();
config::CheckForFileChanges();
utimerCreate(&filecheckTimer, 1e+9L, TimerType_Repeating);
return Enable();
}
void Exit()
{
Disable();
}
Result Enable()
{
if (filecheckTimer.started)
return 1;
utimerStart(&filecheckTimer);
is_config_changed_check_thread_running = true;
return g_config_changed_check_thread.Start().GetValue();
}
void Exit()
void Disable()
{
is_config_changed_check_thread_running = true;
is_config_changed_check_thread_running = false;
utimerStop(&filecheckTimer);
g_config_changed_check_thread.CancelSynchronization();
g_config_changed_check_thread.Join();

View File

@ -28,4 +28,7 @@ namespace syscon::config
Result Initialize();
void Exit();
Result Enable();
void Disable();
};