[Runner]Check for updates and bug report on background thread (#25978)

* [Runner] CheckForUpdatesCallback function and ID_REPORT_BUG_COMMAND case in tray_icon moved to threads.

* [Runner] Bool flag added to bug report thread.

* [Runner] Bool flag added to CheckForUpdatesCallback thread.

* [Runner] Review comments added. Uncessary mutex removed. compare_exchange_strong is used for atomic_bool variable checks.
This commit is contained in:
gokcekantarci
2023-06-05 13:42:06 +03:00
committed by GitHub
parent 0f6305f5fa
commit 4d5152f78a
3 changed files with 31 additions and 11 deletions

View File

@@ -32,6 +32,7 @@
TwoWayPipeMessageIPC* current_settings_ipc = NULL;
std::mutex ipc_mutex;
std::atomic_bool g_isLaunchInProgress = false;
std::atomic_bool isUpdateCheckThreadRunning = false;
json::JsonObject get_power_toys_settings()
{
@@ -106,7 +107,14 @@ std::optional<std::wstring> dispatch_json_action_to_module(const json::JsonObjec
}
else if (action == L"check_for_updates")
{
CheckForUpdatesCallback();
bool expected_isUpdateCheckThreadRunning = false;
if (isUpdateCheckThreadRunning.compare_exchange_strong(expected_isUpdateCheckThreadRunning,true))
{
std::thread([]() {
CheckForUpdatesCallback();
isUpdateCheckThreadRunning.store(false);
}).detach();
}
}
else if (action == L"request_update_state_date")
{