mirror of
https://github.com/cathery/sys-con.git
synced 2024-12-29 03:16:23 +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:
parent
6898d056d4
commit
42f14cd74c
@ -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();
|
||||
|
@ -28,4 +28,7 @@ namespace syscon::config
|
||||
|
||||
Result Initialize();
|
||||
void Exit();
|
||||
|
||||
Result Enable();
|
||||
void Disable();
|
||||
};
|
Loading…
Reference in New Issue
Block a user